简体   繁体   中英

Excel logic, count if larger than 0 (with dates)

I have three columns, each for three periods (1-11, 11-21 and 21-31 i the month). Each of these columns have a top cell with a number representing how many 0's I have in the rows below (a checklist where 1 means DONE and 0 means not done). I also have a column with dates from 1-31. Then I have three cells that tell me "# left period 1, 2 and 3". My issue is that I don't know how to get anything but #DIV/0 if the period has ended, and there are still tasks left to be done. Ie. how to say "If TODAY".

I've added an example file: https://drive.google.com/folderview?id=0B5XqxNeZQfssU19IcFhTQ1R3eG8&usp=sharing

OLD POST:

It works fine counting as long as the period has not ended, then I get a '#DIV/0!'-error. Can someone help me?

It looks like:

Cell with "Tasks left / day Period 1":

 =(K10+(N185/3))/(COUNTIF(Period1[Period \n1];">"&TODAY()))  

K10 is the cell with the total of 0's for this period. N185 is tasks not governed by periods, thus split by 3. Period1[Period 1] is the table and column with the dates that should be counted in Period 1.

Sample data:

 
A1 [formula for tasks left / day period 1 here]

\n\nK10 K11 K12 \n[5] [0] [0] \n\n[1] [1] [1] \n[0] [1] [1] \n[0] [1] [1] \n[1] [1] [1] \n[0] [1] [1] \n[0] [1] [1] \n[0] [1] [1] \n\nN185 \n[3] \n\n[1] \n[1] \n[1] \n[0] \n[0] \n[0] \n\nPeriod1[Period 1] (table) \n2016-03-04 \n2016-03-05 \n2016-03-06 \n2016-03-07 \n2016-03-08 \n2016-03-09 \n2016-03-10 </code></pre> \n

So, if today is 15th of march, the result should be 6 in A1. Now I get '#DIV/0!' as there is no date that is '>' today. With this result I'm ending up pretty blind regarding any backlog.

Your #DIV/0! error is occurring when the number of available data to complete the tasks runs out. However, this also changes the outcome from 'to-be-done' to 'not-completed-in-time' and the divisor should reflect that.

=(K10+(N185/3))/MAX(COUNTIF(Period1[Period 1],">"&TODAY()), 1)

The above will never allow a division by less than 1 and a division by 1 does not affect the number so the numerator and quotient are the same. Similarly, the text label in A2 could be changed to a formula like,

=IF(MAX(Period1[Period 1])<TODAY(), "Left P1", "Left/Day P1")

These changes should be carried across to the formulas in B1:C2.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM