Calculate work days - excel

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

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)

How to identify missing values/duplicate values in excel?

I have four columns of data (day and time A; precipitation amount; day and time B; temperature) the two day and time columns (A and C) should match up (i.e. 16:00 12/10/19 in both columns). However, column A and C have duplicates which are not consistent (e.g. two 16:00 in column A but only one in column C) and I need to retain the duplicates as they contain variations in precipitation or temperature (e.g. A has two reads for precipitation that are biologically important but B does not).
Is there any way I can merge these four columns together by:
-(a) linking A with precipitation amount and C with temperature; and
-(b) without deleting the duplicates but instead placing spaces in either columns where there is space?
Here is my data - red represents duplicates (a tiny subset - I have 365 days and four years of data):
This is what I'd like it to look like (so there is a gap in second column where there isn't a duplicate):
Thank you very very much for any help!! :)
If the duplicate dates are only in column A, then you can recreate the dates and temp values in a helper column. In column E, start in row 2 to pull only the unique dates.
=IF(A5=A4,"",A5)
Copy down. Then in cell F2, use a lookup formula to pull the matching temperature
=XLOOKUP(E5,C:C,D:D,"")
Or, if you don't have Office 365 with the new Xlookup, use Vlookup
=IF(ISNUMBER(E5),VLOOKUP(E5,C:D,2,FALSE),"")
Copy down.
You can then copy the result and use Paste Special > Values to overwrite the original data.
In C2, add this formula, and then fill it down:
=IF(A2=A1,"",A2)
This says if date in the row above it is the same, then return a blank. Otherwise, return the date.

Counting unique values in a column that matches multiple criteria in a single column

I'm trying to count how many values in column A multiple multiple criteria that are mixed in column B. I was able to do this using a helper column (column C). To better get the idea, please see below:
Row Column A Column B Column C
Day Shift Helper
1 Monday Worked AM Worked PM
2 Tuesday Worked AM
3 Wednesday Worked AM Worked PM
4 Monday Worked PM
5 Wednesday Worked PM
Column A contains days from Monday to Wednesday, column B contains shifts while column C contains a formula to return "Worked PM" if that day also has a "Worked PM" somewhere below. Basically, Monday and Wednesday has these in rows 4 and 5.
Formula for cell C1 is =IF(B1="Worked PM","",IF(COUNTIFS($A$1:$A$5,$A1,$B$1:$B$5,"Worked PM")>0,"Worked PM",""))
The reason why I have this helper column is because I want to count the days that have both "Worked AM" and "Worked PM" on them. In our example, the count formula should return 2. I used the following formula, which is working perfectly: =COUNTIFS($B$1:$B$5,"Worked AM",$C$1:$C$5,"Worked PM")
However, I wish to completely eliminate the helper column (column C), which I have failed to do ever since. I tried making use of SUMPRODUCT, COUNT+MATCH and COUNTIFS. I've seen tutorials on how to do this from different Excel help sites, but I've seen nothing that matched my concern. They were "close" (not sure), but when I reconfigure them, I always fail.
I've turned to here as my last stop before giving up. I want to ask if what I'm actually doing is impossible. If it is possible, I would as well seek your guidance on how can I arrive on the solution. Thanks in advance! :)
This will replicate the results from your helper column method. Enter as an array formula (ctrl+shift+enter):
=SUM(--IF(B2:B6="Worked AM",IFERROR(MATCH(A2:A6,IF(B2:B6="Worked PM",A2:A6),0),0)>0))
But unless you have duplicate row entries, wouldn't the count simply equal the number of repeats you have in column A? You don't have to enter this as an array formula:
=SUM(--(FREQUENCY(MATCH(A2:A6,A2:A6),ROW(A2:A6)-ROW(A2)+1)>1))

IF statement formulas

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)))))))

Excel: Finding next equal match in column

I've googled for a solution to my problem for days and I just can't seem to get my head around how to do this.
I have 28 chickens and I track the eggs each one lays each month. My Excel sheet looks like this:
Current Egg-cel sheet
Column C is populated by the formula:
=LARGE($A$2:$A$29,$B1)
I'm using column B to increment the LARGE function
I want column D to populate with which chicken number laid the quantity in column C.
Obviously INDEX MATCH or VLOOKUP returns the first match for all equal values. How do I find the the next match? i.e.
Egg-cell sheet 2
I've seen similar questions and solutions but I for the life of me can not get it to work.
Use this formula in D2:
=INDEX(B:B,AGGREGATE(15,6,ROW($A$2:$A$29)/($A$2:$A$29=C2),COUNTIF($C$2:C2,C2)))
And drag down
If you're happy to add a few helper columns, this is a simple way to go:
The formula in column C creates a unique number by bringing together the eggs laid and the chicken number
=--(A2&"."&B2)
Column D is just your LARGE formula,
=LARGE($C$2:$C$4,B2)
Column E just gets the integer part of column D
=INT(D2)
And finally Column F gets the decimal part (chicken number) from column D
=--REPLACE(MOD(D2,1),1,2,"")

Resources