+ Reply to Thread
Results 1 to 23 of 23

counting problem

  1. #1
    Registered User
    Join Date
    11-01-2012
    Location
    Madisonville, KY
    MS-Off Ver
    Excel 2010
    Posts
    47

    counting problem

    Here is my data set
    A B C
    1 FALSE FALSE
    2 TRUE FALSE 1
    3 TRUE FALSE 2
    4 TRUE FALSE 3
    5 TRUE FALSE 4
    6 TRUE FALSE 5
    7 FALSE FALSE
    8 FALSE FALSE
    9 TRUE FALSE 1
    10 FALSE FALSE
    11 FALSE FALSE

    The formula in column C is =IF(AO44=TRUE,ROW()-LOOKUP(10^99,ROW(AO$6:AO44)/(AO$6:AO44=FALSE)),"")

    My issue is that in C7 there is a blank because both A7 and B7 are False, however if BOTH are false I need the count to continue so that C9 would be an output of 6

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: counting problem

    C1: =IF(AND(A1, NOT(B1)), 1, "")
    C2: =IF(AND(A3, NOT(B3)), MAX($C$1:$C2)+1, "")

    Copy C2 downward.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: counting problem

    Or if the count goes up if EITHER A or B is true, then maybe:

    C1: =IF(SUM(--A1,--B1)>0, 1, "")
    C2: =IF(SUM(--A2,--B2)>0, MAX($C$1:$C1)+1, "")

    Copy C2 downward.


    NOTE: The -- is turning the TRUE and FALSE into 1 and 0.

  4. #4
    Registered User
    Join Date
    11-01-2012
    Location
    Madisonville, KY
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: counting problem

    the formula looks to work, however it shows a value of zero. When i click on the function to check the formula result, it shows a value of 1

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: counting problem

    You have a workbook for me to look at?

  6. #6
    Registered User
    Join Date
    11-01-2012
    Location
    Madisonville, KY
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: counting problem

    here is my actual data (see attachment)

    Look at columns AO, AP, and AQ on the Data tab.

    For column AQ, i need a formula that looks at both AO and AP. If AO6 is True, then AP6 will be false. AQ6 needs to have an output of 1. If both AO6 and AP6 are false, the AQ6should be 0. Starting at AQ7, then if AO7 is true then AQ7 would be 1+AQ6. However if at any time there is a TRUE in column AP, then the count in AQ would stop and start the next time there is a TRUE in column AO.
    Attached Files Attached Files

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: counting problem

    the first formula in AQ7 should be: =IF(SUM(--AO7,--AP7)>0, MAX($AQ$6:$AQ6)+1, 0)

    then copy down.

  8. #8
    Registered User
    Join Date
    11-01-2012
    Location
    Madisonville, KY
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: counting problem

    but what about stopping the count if AP is True?

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: counting problem

    I gave you two versions. The first one is for TRUE/FALSE only, the second one worked for TRUE/FALSE, TRUE/TRUE or FALSE/TRUE.

    Use the first one from post #2.

  10. #10
    Registered User
    Join Date
    11-01-2012
    Location
    Madisonville, KY
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: counting problem

    can you take a look? I input the formulas and not getting the outputs correct

    attached is workbook with formulas input from post #2
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    11-01-2012
    Location
    Madisonville, KY
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: counting problem

    i got that formula to count, however if you look at cell AP44, it shows true so the count in AQ47 needs to be 1 instead on continuing to count and being 5.

  12. #12
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: counting problem

    You keep making the same error over and again. The MAX() reference can't include the cell the formula is in, it has to stop ABOVE the cell.

    So the first cell formula in AQ6 could be: =IF(AND(AO6, NOT(AP6)), MAX($AQ$5:$AQ5)+1, 0)

  13. #13
    Registered User
    Join Date
    11-01-2012
    Location
    Madisonville, KY
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: counting problem

    i understand the above formula now with the MAX function, however i still need the count to start over if the value in AP is ever True

  14. #14
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: counting problem

    Hmm.... missed that entirely. Are the rows the increment always together?

  15. #15
    Registered User
    Join Date
    11-01-2012
    Location
    Madisonville, KY
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: counting problem

    what do you mean always incremental? There may be 5 rows where you have either True or false in AO and AP respectively, and then another 5 where both would be false. If you still have the workbook, unhide all of the columns on the right and you will see the logic. The data is entered on the far left of the DATA tab, and based upon the column (I think it is D) that is called EST #, all of the columns that are hidden look for the EST number in order to know if they populate True or False.

  16. #16
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: counting problem

    I'm not coming up with a simple solution to restart the counting after a False/True row occurs. I was asking if the rows that get the incremental numbers always appear TOGETHER, your example data is short, only shows one group of 5 then another group of 1 with a FALSE/TRUE splitting them. I was wondering if there would ever be 0s in the list and then the prior list continued again, or does it typically always start over again after the 0s start?

  17. #17
    Registered User
    Join Date
    11-01-2012
    Location
    Madisonville, KY
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: counting problem

    here is the logic for this:

    IF True False then count, if another True False then count increases
    If False False then skip
    If False True then start count at next True False

  18. #18
    Registered User
    Join Date
    11-01-2012
    Location
    Madisonville, KY
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: counting problem

    I am attaching a sample larger data set. In the blank areas under the heading pass count and fail count, I can insert a zero instead of a blank if that would be helpful. The sample data in the attachment would represent how it needs to be reflected in columns C and D.
    Attached Files Attached Files

  19. #19
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: counting problem

    In C2 and copied down:

    =IF(A2,IF(IFERROR(MATCH(99^99, $C$1:$C1, 1),0)>IFERROR(MATCH(99^99, $D$1:$D1, 1),0), INDEX($C$1:$C1, MATCH(99^99, $C$1:$C1,1))+ 1, 1), "")

  20. #20
    Registered User
    Join Date
    11-01-2012
    Location
    Madisonville, KY
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: counting problem

    works, thank you very much

  21. #21
    Registered User
    Join Date
    11-01-2012
    Location
    Madisonville, KY
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: counting problem

    Can i get you to look at one more item,

    Using the following formula

    =IF(AO77,IF(IFERROR(MATCH(99^99, $AQ$5:$AQ76, 1),0)>IFERROR(MATCH(99^99, $AR$5:$AR76, 1),0), INDEX($AQ$5:$AQ76, MATCH(99^99, $AQ$5:$AQ76,1))+ 1, 1), "")

    I also need in this formula to say that if AP77=True, then in AQ77 will be zero.

  22. #22
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: counting problem

    Just add new stuff like that at the beginning.

    =IF(AP77, 0, IF(AO77,IF(IFERROR(MATCH(99^99, $AQ$5:$AQ76, 1),0)>IFERROR(MATCH(99^99, $AR$5:$AR76, 1),0), INDEX($AQ$5:$AQ76, MATCH(99^99, $AQ$5:$AQ76,1))+ 1, 1), ""))

  23. #23
    Registered User
    Join Date
    11-01-2012
    Location
    Madisonville, KY
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: counting problem

    figured that out after i posted this, thanks again

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1