IF statement formulas - excel

Need assistance with creating a formula to calculate how many days of storage. The attached image of a spreadsheet that I use shows an array of dates.
I need a formula in column "E" "Live Days in SIT" that calculates the following:
1st: If column D & C have dates, subtract column D from C
2nd: If all columns have date, subtract column D from C
3rd: If column C is only cell with dates, subtract Todays date from column C
4th: If column C & B have dates, then subtract B from C
5th: If column C & A have dates, then subtract A from C
6th: If column A, B, C have dates, subtract the lesser dates from columns A & B from C
This is the formula I have created, but I receive a "False" statement when only column C has a date:
=IF(L4758=0,IF(J4758=0,IF(I4758=0,TODAY()-K4758)),IF(L4758>0,L4758-K4758,IF(L4758=0,IF(I4758=0,IF(J4758>0,J4758-K4758,IF(J4758<I4758,IF(J4758>0,J4758-K4758,IF(J4758>I4758,IF(I4758>0,I4758-K4758)))))))))
Thank you!

Try,
=if(count(a2:d2)=4, c2-d2, if(count(a2:c2)=3, c2-min(a2:b2), if(and(count(a2:d2)=2, c2<>0), c2-sum(a2, b2, d2), text(,))))
There are still some 'holes' in your logic but I suppose those are conditions that will never be met.

This should work, but I got a little confused as to which column should be subtracting from which. I followed your verbal commands, but my intuition says you probably are looking for a different method than the one you described. Here it is, you can adjust if need be.
=IF(AND(C6<>"",D6<>""),C6-D6,IF(AND(D6<>"",C6<>"",B6<>"",A6<>""),C6-D6,IF(AND(D6="",C6<>"",B6="",A6=""),C6-TODAY(),IF(AND(C6<>"",B6<>""),C6-B6,IF(AND(C6<>"",A6<>""),C6-A6,IF(AND(A6<>"",B6<>"",C6<>""),IF(A6>B6,C6-B6,C6-A6)))))))

Related

Number occurrences in another cell (Excell) [duplicate]

I have simple problem, but I've not be able to get an answer from searching. I require a column to calculate the number of the nth occurrence of a value. It's best explained in this picture
I require a method to calculate column B.
I'd be very grateful for any help.
Are you looking to merely provide a count of the distinct entries of column A in column B? Or merely add a formula to come up with the table in your link?
If the latter, then the formula to write in cell B2 is:
=COUNTIF(A$2:A2,A2)
then copy/paste it down column B. Note - if your data is both a Date and Time, but the cell is formatted to only display a date, you may not get the results you want. You'd need to interject a new column with a "floor" calculation to round the date/time value to a date (Excel date times are decimal, with integer part dictating the date, and remaining 0.0 -> 1.0 dictating the time of day)
If you just want to derive a table of the counts of distinct entries in column A, then a pivot table will do this for you - simple add a pivot table to cover the data in column A, then select column A into the rows category, and then also drag it into the values category, ensuring the field is set to "Count of". You should then have a table with the distinct entries in your data set in one column, and the count of their occurrences in the other column.
You can use the COUNTIF worksheet function, with a relative address.
Eg. In cell B2, enter this formula:
=COUNTIF(A$2:A2,A2)
And then fill-down.
Use the following formula to generate the required series:
=COUNTIF($A$1:A1,A1) and strech(copy) it in all the cells
This will generate result like this:
A 1 COUNTIF($A$1:A1,A1)
A 2 COUNTIF($A$1:A2,A2)
C 1 COUNTIF($A$1:A3,A3)
C 2 COUNTIF($A$1:A4,A4)
B 1 COUNTIF($A$1:A5,A5)
B 2 COUNTIF($A$1:A6,A6)
A 3 COUNTIF($A$1:A7,A7)
C 3 COUNTIF($A$1:A8,A8)
D 1 COUNTIF($A$1:A9,A9)
D 2 COUNTIF($A$1:A10,A10)
D 3 COUNTIF($A$1:A11,A11)
D 4 COUNTIF($A$1:A12,A12)

Calculate work days

I want to calculate work days between two dates. NETWORKDAYS will do the trick, however I am having difficulty structuring the IF statement components.
I have 5 columns, Column A will always have a start date; the other 4 columns might not. What I want to calculate is the network days between Column A and B, but if B is blank then Column A and C, and if C is blank, then Column A and D and so forth
Use this formula:
=NETWORKDAYS(A1,INDEX(A1:E1,AGGREGATE(15,6,COLUMN(B1:E1)/(B1:E1<>""),1)))
The INDEX/AGGREGATE will find the first cell in B:E that is not empty and return that as the end date to the NETWORKDAYS.
=IF(A1<>"",NETWORKDAYS(A1, B1), IF(C1<>"", NETWORKDAYS(A1, C1)))
This does the trick, I could not get AGGREGATE/INDEXto work

Calculate Occurrence Number - Excel

I have simple problem, but I've not be able to get an answer from searching. I require a column to calculate the number of the nth occurrence of a value. It's best explained in this picture
I require a method to calculate column B.
I'd be very grateful for any help.
Are you looking to merely provide a count of the distinct entries of column A in column B? Or merely add a formula to come up with the table in your link?
If the latter, then the formula to write in cell B2 is:
=COUNTIF(A$2:A2,A2)
then copy/paste it down column B. Note - if your data is both a Date and Time, but the cell is formatted to only display a date, you may not get the results you want. You'd need to interject a new column with a "floor" calculation to round the date/time value to a date (Excel date times are decimal, with integer part dictating the date, and remaining 0.0 -> 1.0 dictating the time of day)
If you just want to derive a table of the counts of distinct entries in column A, then a pivot table will do this for you - simple add a pivot table to cover the data in column A, then select column A into the rows category, and then also drag it into the values category, ensuring the field is set to "Count of". You should then have a table with the distinct entries in your data set in one column, and the count of their occurrences in the other column.
You can use the COUNTIF worksheet function, with a relative address.
Eg. In cell B2, enter this formula:
=COUNTIF(A$2:A2,A2)
And then fill-down.
Use the following formula to generate the required series:
=COUNTIF($A$1:A1,A1) and strech(copy) it in all the cells
This will generate result like this:
A 1 COUNTIF($A$1:A1,A1)
A 2 COUNTIF($A$1:A2,A2)
C 1 COUNTIF($A$1:A3,A3)
C 2 COUNTIF($A$1:A4,A4)
B 1 COUNTIF($A$1:A5,A5)
B 2 COUNTIF($A$1:A6,A6)
A 3 COUNTIF($A$1:A7,A7)
C 3 COUNTIF($A$1:A8,A8)
D 1 COUNTIF($A$1:A9,A9)
D 2 COUNTIF($A$1:A10,A10)
D 3 COUNTIF($A$1:A11,A11)
D 4 COUNTIF($A$1:A12,A12)

How can I SUMIF where the IF evaluates whether a date is between two dates?

UPDATE: The contents of Column K were not, in fact, formatted as numbers all the way through.
Given:
Column F_____Column K_____Column M
3/1/2015_____1____________2/1/2015
2/1/2015_____2____________3/1/2015
2/1/2015_____3____________4/1/2015
where columns F and M are formatted as dates and K as numbers. Column F is not sorted, Column M is. Every date is for the 1st of its month.
I want to populate Column N such that each row sums the elements in column K whose corresponding value in Column F is in the month of Column M.
Tried:
SUMIF($F$2:$F$12500, AND(">="&M2, "<"&M3), $K$2:$K$12500)
Get zeroes across the board. Evaluating whether row 2 Column M and row 1 Column F are equal yields TRUE. What's going on?
With the assumption that all dates are the first of the month you don't have to restrict it to being in between the 2 dates on F:F but just rather that the dates has to match M2. With that in mind you can simply do the following:
N2 = SUMIF(F:F,M2,K:K)
This will add all the values in K:K for rows that have the same month (hence exact same date) as M2. Hope I interpreted your question correctly. Regards.

Count 'Yes' from column K where year is 2014 in column B?

I am trying to create an excel formula which will count all of the occurrences of the word 'Yes' in my column K where the year of the date in column B is '2014'.
Column B Column K
01/02/2014 Yes
03/04/2014 No
06/01/2014 Yes
08/02/2015 Yes
So I know how to get the year from my date in column b
=YEAR(B:B)
But now I want to combine this and put it into a countif formula which will count all of the yes's in my column k where the year in column b is 2014.
here's what I've tried to put together:
=COUNTIF(K:K="Yes",YEAR(A:A)=2014))
This doesn't work, please can someone show me where I'm going wrong.
Try this:
=SUMPRODUCT(--(YEAR($A$2:$A$5)=2014),--($B$2:$B$5="Yes"))
To make it more dynamic, i.e.: get the criteria from the matching row data, change the formula to this:
=SUMPRODUCT(--(YEAR($A$2:$A$5)=YEAR(A2)),--($B$2:$B$5=B2))
EDIT:
Maybe this is what we need, paste below formula to C2:
=SUMPRODUCT(--(YEAR($E$2:$E$5)=A2),--($F$2:$F$5=B2))
Maybe not the most elegant solution, but this would work :
Create 3rd column with formula : =YEAR(A2) & B2
And to get your count use : =COUNTIF(C2:C5; "2014Yes")

Resources