I have two data sources one is forecast hours for a job the other is actual hours, currently I have this formula to automatically change between the two data sets:-
=IF(K2<='Raw Data'!$A$1,'[Actual Hours.xlsx]Actual Time & Cost - All Suffix'!I84,'Raw Data'!B3))
Though currently it shows no value for the current month (i.e July) I have tried the following but with no success:-
=IF(K2='Raw Data'!$A$1,'Raw Data'!B3,IF(K2<='Raw Data'!$A$1,'[Waterside Forcast Hours.xlsx]Actual Time & Cost - All Suffix'!I84,'Raw Data'!B3))
Any help would be appreciated.
The logic of the second sample formula can be described in these three hierarchical steps.
If K2 is equal to A1 on 'Raw Data' then use 'Raw Data'!B3
If K2 is less than or equal to A1 on 'Raw Data' then use the external 'Actual Time & Cost - All Suffix'!I84
In all other cases, use 'Raw Data'!B3.
It seems like that can be pared down to two steps.
If K2 is less than A1 on 'Raw Data' then use the external 'Actual Time & Cost - All Suffix'!I84
In all other cases, use 'Raw Data'!B3.
The chopped down formula closely resembles the first with the exception of changing <= to <.
=IF(K2<'Raw Data'!$A$1,'[Waterside Forcast Hours.xlsx]Actual Time & Cost - All Suffix'!I84, 'Raw Data'!B3)
Perhaps you are trying to compare to the month and year (or the first/last of the current month).
Thanks to #Jeeped for his advise on this problem. Here is the formula which I finally used which solves the problem:-
=IF(MONTH($K$2)<MONTH('Raw Data'!$A$1),'[Actual Hours.xlsx]Actual Time & Cost - All Suffix'!I84,'Raw Data'!B3)
Feel free to give feedback.
Cheers
Related
I am in the process of building a formula to split a total cost (in column J) based on start and end expenditure periods that can vary from 2021 to 2031. Based on the days between the expenditure period dates (column M), I managed to work out to split the cost using the formulas below up to 2023 but it is not consistent and at times incorrect.
In cell P5 I have the following formula. For year 2021, I seem to get the correct split result.
=IF($K5>AS5,0,$J5/$M5*(AS5-$K5))
In cell Q5, I have the following formula. For year 2022, I seem to get the correct spit as well
=MIN(IF(SUM($N5:P5)>=$J5,0,IF($L5>=AS5,$J5/$M5*(AS5-AR5),$J5/$M5*($L5-MAX(AR5,$K5)))),K5)
However, I don't get the right result in cell Q6 which has the same formula but different dates
=MIN(IF(SUM($N6:P6)>=$J6,0,IF($L6>=AS6,$J6/$M6*(AS6-AR6),$J6/$M6*($L6-MAX(AR6,$K6)))),K6)
Cell R6 shouldn't return any result because it is out of date range. This is where things get mixed up.
Note that from column AR to BC, it is all year end dates from 2020 to 2031 as shown below.
Is there a better way to tackle this sort of formula as I seem to get dragged into a long and unreliable way of doing this.
Here single function(♣) that will create a series of pro-rata multipliers (of appropriate length) for any given start/end date:
EDIT: see end of soln for extended version per OP comment to original soln...
SINGLE FUNCTION
=J11*(LET(dates,EDATE(DATE(YEAR($K11),1,1),12*(SEQUENCE(1,YEAR($L11)-YEAR($K11)+2,1))),IF(dates<K11,K11,IF(dates<L11,dates,L11)))-LET(dates,EDATE(DATE(YEAR($K11)-1,1,1),12*(SEQUENCE(1,YEAR($L11)-YEAR($K11)+2,1))),IF(dates<K11,K11,IF(dates<L11,dates,L11))))/(L11-K11)
It may appear somewhat unwieldy in length, but it is far more robust (and concise) compared to the combination of steps/series you have created. What's more, it returns the precise answer RE: pro-rata payments and is guarenteed to never over/under-run RE: total payment (by design).
BREAK-DOWN
Comprises 3 distinct parts (some of which are similar in pattern/formation):
1] First part - create a series (array) of years spanning start-end dates:
=LET(dates,EDATE(DATE(YEAR($K5)-1,1,1),12*(SEQUENCE(1,YEAR($L5)-YEAR($K5)+2,1))),IF(dates<K5,K5,IF(dates<L5,dates,L5)))
Thanks to the lovely Spill functionality the new Office 365 variant Excel boasts, you never have to worry about how many years are required -- so long as you have the space to the right of this workbook (would be unusual otherwise - assuming you start in column O and clear any content to the right of this, you'd need an end date beyond the year 2557 (26th century) to run out of columns! ☺
2] Second part is merely a replica of the firs series, albeit shifted to the right 'once' (so starts with the 2nd element in the 1st series):
=LET(dates,EDATE(DATE(YEAR($K5),1,1),12*(SEQUENCE(1,YEAR($L5)-YEAR($K5)+2,1))),IF(dates<K5,K5,IF(dates<L5,dates,L5)))
3] Third part - you have the basic ingredients from parts 1 and 2 to complete the required task easily: simply deduct series 2 from 1 (giving days between successive dates in series 1 - i.e. days for each year between start and end dates), divide by total days (to yield pro-rata multipliers), and then multiply these by the total £amount and voila - you have your series!
=J5*(O6#-O5#)/(M5)
♣ Caveat(s) - assuming you have Office 365 compatible version of Excel (which is quite common nowadays)
*EDIT - EXTENDED VERSION
Given above, the following extends this to align monetary results (1st table, o11:w21) within respective calendar period columns (spanning the entire period in question).
This soln:
Determines header row based upon the number of columns & corresponding calender periods (financial yrs commencing 1/1) as an array function (i.e. dynamic range)
Utilises a modified version of the eq. provided for dates arrage (refer: "First Part", original soln)
Comment - same caveats as before - i.e. Office 365 etc.
Screenshot(s)/here refers:
DATES (HEADER) - Y10 (array)
=LET(y_,MIN(K11:K21),x_,MAX(L11:L21),EDATE(DATE(YEAR(y_)-1,1,1),12*(SEQUENCE(1,YEAR(x_)-YEAR(y_)+2,1))))
Comment - enter once within single cell Y10 - i.e. as an array function with Spill to right
ALIGNED/SHIFTED FINANCIALS - Y11:Y21 (each cell in col is an array)
=IFERROR(IF(Y$10#<EDATE(K11,-12),"",IF(Y$10#>EDATE(L11,12),"",INDEX(O11#,1,MATCH(Y$10#,EDATE(DATE(YEAR($K11)-1,1,1),12*(SEQUENCE(1,YEAR($L11)-YEAR($K11)+2,1))),0)))),"")
Comment - enter this as an array fn. (#SPILL! to the right) in each cell within column Y (can drag this function down Y11:Y21 as required)
I have Excel data as per the below screenshots. I am trying to find whether it is "Out Hours" or " Business Hours" based on the start time and close time.
If time is between the start and close time, it should return "Business Hours" else " Out Of Hours".
=IF(B4=MEDIAN(B2,C2,B4),"Business Hours","Out Of Hours")
Here is a massive article about dealing with time -
https://www.ablebits.com/office-addins-blog/2015/06/24/calculate-time-excel/.
You will find everything you need.
I have found this working for you:
=IF(AND(HOUR(B4)+MINUTE(B4)/60>=8;HOUR(B4)+MINUTE(B4)/60<=17);"IN";"OUT")
I don't understand why you involve the median into this formula, you can simply do this:
=IF(AND(B4>=B$2;B4<=C$2);"BUSINESS HOURS";"OUTSIDE HOURS")
Simply said: if B4 lies between B$2 and C$2, then it's "BUSINESS HOURS", else it's outside. I'm using dollarsigns for absolute cell referencing (if you drag your formula to the next row, the value $2 doesn't change).
I am trying to get the averages of a column that meet certain criteria into a single cell.
The following formula works: =AVERAGEIFS(tblData[Sys],tblData[Time],">=12:00 PM",tblData[Time],"<6:00 PM") but when I adjust the time values to: =AVERAGEIFS(tblData[Sys],tblData[Time],">=6:00 PM",tblData[Time],"<4:00 AM") I get an error. I'm guessing it's because the time range goes into the next day.
Is there a better function to use or a workaround?
This formula seems to work for you scenario. It checks for the possibility that the end time is before the start time (but on the next day) and changes the logic accordingly:
=AVERAGE(
IF(
IF(tmStart>=tmEnd,
(tblData[Time]>=tmStart)+(tblData[Time]<=tmEnd),
(tblData[Time]>=tmStart)*(tblData[Time]<=tmEnd))
=1,tblData[Sys],""))
It's important to understand this function does, and the underlying intentions are - I elaborate in the what follows, proffer a workable solution, provide a reconciliation, as well as a link to the workbook with screenshot below.
You will need to specify # days spanned - even the scenario that 'worked' for you (i.e.. =AVERAGEIFS(tblData[Sys],tblData[Time],">=12:00 PM",tblData[Time],"<6:00 PM") could, in theory, span 2 (or more) days. The fact that this 'works' (doesn't return #DIV/0!) is that the 'intersection' of conditions is an non-empty set (i.e. {12pm-5pm}).
As I say, if this was intended to be ">=12:00" from day 1 through to "<6pm" the following, there is no way of determining whether this is indeed the case by simply 'comparing the times' (e.g. 12pmvs 6pm).
Screenshot/here refer::
=IF($I$5="Y",(SUM(1*($C$5:$C$28*(($D$5:$D$28>=$J$3)+1*($D$5:$D$28<$K$3)))))/SUM((($D$5:$D$28>=$J$3)+1*($D$5:$D$28<$K$3))),IFERROR(AVERAGEIFS(C5:C28,D5:D28,">="&J3,D5:D28,"<"&K3),"times don't intersect! "))
where: I5 = 'Y' or 'N' (i.e. multiple days'). When scenario B is selected, with multiple days = 'Y', outcome = 12.9 which reconciles to a manual calculation.
I'm trying to find a way to distribute revenue to specific dates and weight out the numbers. So that if a day falls between my two reporting days, I want it to allocate it based on the difference between the reporting days. So for example if I have reporting dates
20/11/2017
30/11/2017
10/12/2017
20/12/2017
and sale dates with revenue
Sales dates Volumes
22/11/2017 600,000,000
12/12/2017 -100,000,000
13/12/2017 -141,400,000
20/12/2017 -100,962,000
I want the sale made 22/11/2017to be distributed 8/10 to 20/11/2017and 2/10 to 30/11/2017and so on, so that the 4 sales would distribute to
Reporting dates
20/11/2017 480,000,000
30/11/2017 120,000,000
10/12/2017 -178,980,000
20/12/2017 -163,382,000
I have not successfully found any solution, anyone know if I have missed something or have any good ideas how one good build such a settup?
Ok, this solution uses a lot of helper columns as I haven't had time to condense it all down. I'm sure these formula can be improved and maybe even turned into a single formula.
First step is to find the two dates that your revenue should be distributed between.
With your original data in cells A1:B4 this formula placed in cells C1:C4 will return the higher date:
=DATE(YEAR($A1),MONTH($A1),CEILING(DAY($A1),10))
and this, placed in D1:D4 will return the lower date:
=DATE(YEAR($A1),MONTH($A1),FLOOR(DAY($A1),10))
Edit: After spending a bit more time awake you could replace the above two formula with =CEILING($A1,10)-1 and =FLOOR($A1,10)-1 respectively.
Next we find where the sale date is in relation to the upper and lower dates.
In E1:E4 use:
=(C1-A1)/10
and in F1:F4:
=(A1-D1)/10
Now to return the revenue based on that distribution:
In G1:G4 use:
=E1*$B1
The formula in H1:H4 differs slightly as the 100% figure should only be returned once. The revenue for 20/12/2017 will only appear in column H.
=IF(F1=0,B1,F1*$B1)
I've placed the reporting dates in the range J1:J4; so 20/11/2017 in J1, 30/11/2017 in J2, etc.
The formula in K1:K4 is:
=SUMIF(C$1:C$4,$J1,$H$1:$H$4)
The formula in L1:L4 is:
=SUMIF(D$1:D$4,$J1,$G$1:$G$4)
Finally the formula to return your distribution will sum the previous two formula in cells M1:M4:
=SUM(K1:L1)
I am working on a financial model in excel. If the number of customers is between 1-10000, the cost is .20 per customer per month, 10000-100000 is .15 per customer per month, 100k and 1MIL is .10 per customer per month and > 1MIL is .08 per month per customer.
What I would like to do is create a formula where if the cell that references the number of customers at that month is within those values above, the cost per month changes depending on the number of cstomers.
This is what I have:
=IF(AND(B6>=1,B6<=10000),$Q$6), IF(AND(B6>10000,B6<=100000),$Q$7), IF(AND(B6>100000,B6<=1000000),$Q$8),IF(AND(B6>1000000),$Q$9)
Q6, Q7, Q8, Q9 are respectively: $.20, $.15, $.10, $.08
My B6 cell is the cell that is pulling over the number of customers from another sheet.
I am getting a #VALUE! Error when I use this formula. It works if I simply have:
=IF(AND(B6>=1,B6<=10000),$Q$6) which leads me to believe that my logic is wrong with all of the IF statements, and I should be using ELSEIF but I am not sure the syntax for that.
Help is appreciated!
So this is how I fixed this issue in case anyone had the same issue:
=IF(B6<=10000,$Q$6,IF(B6<=100000,$Q$7,IF(B6<1000000,$Q$7)))
By nesting the if statements with higher values excel automatically recognizes the max value for that if statement!
It seems that you are closing the IF statements too soon. Your formula repaired would look like,
=IF(AND(B6>=1,B6<=10000),$Q$6, IF(AND(B6>10000,B6<=100000), $Q$7, IF(AND(B6>100000,B6<=1000000), $Q$8, IF(AND(B6>1000000),$Q$9))))
If you start at the upper limit, you can reduce the conditions with sequential logic.
=IF(B6>1000000,$Q$9, IF(B6>100000, $Q$8, IF(B6>10000, $Q$7, IF(B6>=1,$Q$6, 0))))
You could probably do that a little more easily like this
=IF(B6>1000000,$Q$9,IF(B6>100000,$Q$8,IF(B6>10000,$Q$7,IF(B6>=1,$Q$6,"Error))))
You don't need AND because the IF functions are implicitly checking a range because the previous IFs rule out ranges of values