I have a sheet in WB1 that looks like this:
A B C
Row Supplier PO_Date Delivery_Days
...
2091 A 8/2/2018 5
2092 B 8/5/2018 4
2093 C 8/7/2018 1
2094 B 8/8/2018
2095 B 8/8/2018 -7
2096 B 8/8/2018 -7
2097 C 8/17/2018 5
2098 D 8/22/2018
2099 D 8/22/2018 2
2100 A 8/28/2018 -3
2101 E 8/30/2018 4
2102 A 8/31/2018
2103 A 8/31/2018 12
...
And in WB2, I have a cell that is meant to calculate the average delivery days, but only including specific suppliers and adjustable start and end dates in cells B1 and B2. That function looks like this:
=AVERAGE(AVERAGEIFS('[WB1.xlsx]Sheet 1'!$C:$C,
'[WB1.xlsx]Sheet 1'!$A:$A, {"A", "B", "C"},
'[WB1.xlsx]Sheet 1'!$B:$B,">=" & B1,
'[WB1.xlsx]Sheet 1'!$B:$B,"<=" & B2))
This function does not produce the value I want, though. I want to calculate the average delivery days for all the POs from these specific suppliers, not the average of the average delivery days for the POs for each supplier. (Basically, I want to sum up all the Delivery Days ONCE, not sum and divide within each supplier, then sum and divide those averages.)
How do I need to change the formula? Or should I use a different formula all together?
posting comment as answer so this can be marked appropriately in the queue:
have you tried sumifs() then countifs() so you divide those to get your average, ensuring only one division? – Cyril 31 mins ago
#Cyril Hadn't thought of that, but just implemented it and it's working great. Thank you. – Millie 15 mins
Related
Dates when the data was read are shown on the date column on the left, then worked out a value per day shown in ET/DAY column.
To analyze monthly data etc etc I want daily data so every day has the ET/DAY value between the dates it was read and inserted in the et/day column.
I have entered in manually what I want in blue but need a formula to do this as too long to do all manually
You can do this with MATCH. With an ascending list, if you give the magic number 1 as the third parameter, it will show the last row number with a smaller or equal number.
Here it's matched 17 with 15 in column A and the result is 2, for row 2:
A
B
C
1
10
=MATCH(17,A:A,1) = 2
2
15
3
20
So for your data, you can match the daily dates with the column on the left, and feed the row number into INDEX to look up from the ET/Day column.
A
B
C
D
E
1
Date
ET/Day
Daily
ET/Day
2
05/Jan/1995
05/Jan/1995
=Index(B:B, Match(#D:D,A:A,1)) = #N/A
3
19/Jan/1995
3.00
06/Jan/1995
=Index(B:B, Match(#D:D,A:A,1)) = 3.00
4
02/Feb/1995
5.41
07/Jan/1995
=Index(B:B, Match(#D:D,A:A,1)) = 3.00
5
...
...
6
19/Jan/1995
=Index(B:B, Match(#D:D,A:A,1)) = 3.00
7
20/Jan/1995
=Index(B:B, Match(#D:D,A:A,1)) = 5.41
There's an inconsistency here with the 05 Jan rate but it should be good after that.
I would like to have an overview of averages achieved in column H for each day of the week. The daily Averages should go into smaller table as per below. Thanks in advance.
You can do this, combining AverageIf() and Weekday() function, as in the following example I've created:
A B C
========== = =================
11/10/2021 6 =WEEKDAY(A1,2)=1
12/10/2021 8 =WEEKDAY(A2,2)=1
13/10/2021 5 =WEEKDAY(A3,2)=1
14/10/2021 8 =WEEKDAY(A4,2)=1
15/10/2021 6 =WEEKDAY(A5,2)=1
16/10/2021 4 =WEEKDAY(A6,2)=1
17/10/2021 2 =WEEKDAY(A7,2)=1
18/10/2021 2 =WEEKDAY(A8,2)=1
19/10/2021 6 =WEEKDAY(A9,2)=1
20/10/2021 8 =WEEKDAY(A10,2)=1
Afterwards, I've created the formula:
=AVERAGEIF(C1:C10,"TRUE",B1:B10)
This formula calculates the average of the values in column B for all Mondays in column A.
How does this work?
The Weekday() function calculates the number of the day of the week, based on a switch: when the switch is "2", it sees Monday as 1, Tuesday as 2, ...
The AverageIf() function then:
Checks the column C for the values to be checked
Checks those values against "TRUE"
Calculates the average of the B column for the values, obeying the aforementioned criteria.
A B C D E F G H
1 Products Date Sales Criteria 1: Product_B Result: 200
2 Product_A 2020-04-15 500 Criteria 2: 2020-04-15
3 Product_B 2020-04-12 600
4 Product_B 2020-04-12 300
5 Product_B 2020-04-15 200
6 Product_B 2020-04-20 400
7 Product_C 2020-04-15 800
8 Product_C 2020-04-19 900
9 Product_C 2020-04-30 300
10
11
In the table above I have different products and their sales on a certain date.
In Cell G1 I calculate sum of the sales based on the criterias in Cell E1 and E2.
G1 = SUMPRODUCT((($A$2:$A$100=$E$1)*($B$2:$B$100=$E$2)*$C$2:$C$100))
All this works exactly as it should.
Now, I want to include an IF-Condition that says if you enter the words "All Products" into Cell E1 the product condition ($A$2:$A$100=$E$1) in the SUMPRODUCT should not be applied.
Therefore, I tried to go with this:
= SUMPRODUCT((IF(E1="All Products",1,($A$2:$A$100=$E$1))*($B$2:$B$100=($E$2))*$C$2:$C$100))
Unfortunately, this solution only works if I enter "All Products" into Cell E1.
Once I switch back to Product_B it displays 0 instead of 200.
What do I need to change to make it work?
NOTE:
I know one solution could be to split the SUMPRODUCT into two formulas like this:
=IF(E1="All Products",SUMPRODUCT((($B$2:$B$100=$E$2)*$C$2:$C$100)),SUMPRODUCT((($A$2:$A$100=$E$1)*($B$2:$B$100=$E$2)*$C$2:$C$100)))
However, I would prefer a solution with one SUMPRODUCT-Formula.
With SUMIFS:
=SUMPRODUCT(SUMIFS($C:$C,$A:$A,IF(E1="All Products","*",$E$1),$B:$B,$E$2))
Combining with your LAST QUESTION
=SUMPRODUCT(SUMIFS($C:$C,$A:$A,IF(E1="All Products","*",$E$1),$B:$B,$E$2:$E$3))
Modify the column A criteria as follows:
=SUMPRODUCT((($A$2:$A$100=$E$1)+($E$1="All Products")*($A$2:$A$100=$A$2:$A$100))*($B$2:$B$100=$E$2)*$C$2:$C$100)
The new factor +($E$1="All Products")*($A$2:$A$100=$A$2:$A$100) will ensure a vector of all 1 with the appropriate input in E1:
Array (Control+Shift+Enter) formula in F2
=SUMPRODUCT(IF((E1<>"All Products"),(A2:A9=E1),TRUE)*(B2:B9=E2)*(C2:C9))
Following Array formula is better than the above one. If you enter anything that doesn't match in column A it will consider it as "All Products"
=SUMPRODUCT(IF(COUNTIF(A2:A9,E1)=0,TRUE,(A2:A9=E1))*(B2:B9=E2)*(C2:C9))
OR
=SUMPRODUCT(IF(ISNA(MATCH(E1,A2:A9,0)),TRUE,(A2:A9=E1))*(B2:B9=E2)*(C2:C9))
I am in much need of help please.
I have the table below.
It has about 300 rows and columns on the right for each day of the year starting 2015, ending 2019. I only entered a few columns here as an example.
What I need:
A formula to split the time (it can be hours or decimal days, it doesn't matter) between the two days on the left on the columns to the right.
In the rest of the days, which are not included in the period, I need a zero in those columns.
I manually entered the results I need so it can help you understand.
E.g.
On the first row:
The employee has spent
15 hours at destination in the first day of travel,
24 hours in the second day of travel
11:50 hours in the last day of travel.
All the rest of the columns to the right, which are not here, starting 1/4/2015 23:59 should give the result zero.
Thank You!!
Entry Date Exit Date 1/1/2015 23:59 1/2/2015 23:59 1/3/2015 23:59
1/1/15 9:00 1/3/15 11:50 15.00 24.00 11.50
As far as I can tell, it boils down to this
1.0 days 2.0 days 3.0 days 4.0 days
period=p in h/d.d p-(1-(so far)) p-(2-(so far)) p-(3-(so far)) 0
EDIT 2: I've come up with a formula.
NOTE:
This formula assumes existence of a column that specifies 0 hours of work between the "end date/time" column ("B") and first work hour ("D"), so you have it like this:
A B C D E F G H
1 Entry Date Exit Date ZERO 1/1/2015 23:59 1/2/2015 23:59 1/3/2015 23:59 1/4/2015 23:59 1/5/2015 23:59
2 1/1/15 9:00 1/3/2015 11:50 0 0.6243055556 1 0.49375 0 0.00
3
The extra column is there to avoid circular dependencies, since
we must "iteratively" accumulate the hours
The main formula for row 2 from column D being:
=MIN(D1-$A2,MIN(MAX(($B2-$A2) - SUM($C2:C2), 0),1))
Note: semicolons may be needed instead of commas in Excel as delimiters.
Note: the last digit in the formula depends on the unit. Here it is in days decimal. If hours, put 24.
In plain English, for a cell
Calculate sum of hours/days decimal in the range C to wherever - 1
Subtract result from the difference between start and end (total hours)
If less than 0, put 0 (MAX(x, 0))
If more than 1, put 1 (MIN(x, 1))
Choose between the result, or the difference between current date and start time, if it is smaller
I have this sample data:
A B C D E F
1/11/2015 1 6:00 PM 1
1/11/2015 1 11:00 PM 1
1/12/2015 2 7:30 AM 1
1/12/2015 2 10:00 PM 1
1/14/2015 4 2:00 AM 1
1/15/2015 5 9:00 AM 1
1/16/2015 6 1:00 AM 1
I want to calculate the time in hours between the dates if the value in column E is 1.
I know the formula to calculate the time difference is =(A1+C1)-(A2+C2).
The issue is how to just calculate it if E is 1 and how to get it to handle the gap. (for example, the formula might be F2=(A1+C1)-(A2+C2) or it might be F4=(A1+C1)-(A4+C4).
thanks!
Assuming you want to subtract the date/time from the previous row with 1 in col E from the current row then you can use this approach in Excel (not tested for google).
Use this formula in F2 - custom format as [h]:mm and copy down column
=IF(E2=1,A2+C2-LOOKUP(2,1/E$1:E1,A$1:A1+C$1:C1),"")