Excel - SUMIF Function - excel

I made a worksheet covering meal expenses for a set period of time (01-08-2020 until 31-08-2020.)
The company will pay up to 75kr, Monday-Friday.
The list covers expenses 7 days a week, If the amount is greater than 75 on Monday-Friday, I have to pay the extra expenses. (This I have figured out correctly). Saturday and Sunday I have to pay fully.
So my question is, how can I sum this and exclude Saturday and Sunday?
Attempt 1:
I tried this formula (Norwegian excel. Summerhvis = SUMIF. Lørdag = Saturday):
=SUMMERHVIS(B2:B32,"<>lørdag", G2:G32)
It seems to be partly correct however, I miss Sunday, how can I add Sunday to this equation?
Attempt 2:
I used this formula:
=SUMMERHVIS(B2:B32,B2:B6,G2:G32)
It gave the correct answer but the answer was layered in 5 rows. I then summed this in P8.
Where I want the answer is in G32. So in G32 I wrote =p8.
It must be an easier way of doing this?

You can use SUMPRODUCT and the WEEKDAY function:
=SUMPRODUCT((WEEKDAY(A2:A32,3)<5)*G2:G32)
According to the Microsoft function translator, this might be, in Norwegian:
=SUMMERPRODUKT((UKEDAG(A2:A32;3)<5)*G2:G32)
If you really want to use SUMIF and your text days, one way would be (in English):
=SUM(SUMIF(B2:B32,{"Monday";"Tuesday";"Wednesday";"Thursday";"Friday"},G2:G32)),
or, if your weekday days are in b4:b8:
=SUM(SUMIF(B2:B32,$B$4:$B$8,G2:G32))
but I'd advise against it as it would only work in the language of the text days of the week. Also, I note your days of the week don't seem to match up with what the days of the week were in the US. For example, here 1 Aug 2020 was a Saturday, so another possible cause for error (unless I am not understanding the dates correctly).
The above is the same as summing five separate SUMIF equations, each for a desired day of the week.

Related

Excel Date difference without weekend days

Last time I posted a quite vague story about a date difference challenge which I haven't solved yet. I will try to elaborate since I have tried everything in my power and the problem still isn't fixed.
I currently have three columns.
Column 1 (F)
the date a car starts its repairs (format DayOfWeek-DD-MM-YYYY)
Column 2 (G)
the number of days in which the car is repaired (service level agreement [SLA]; the standard is 10 days)
Column 3 (H)
the output, which is the date the car should be finished. So the number of days after the startdate*
*Th thing which makes this case difficult is that only weekdays are included.
So, for example:
If a car starts repairs on Monday 1st of August, the finish date is Tuesday the 14th of August.
I tried to solve this with the following formula:
=IF(WEEKDAY(F218)=2;(F218+11);
IF(WEEKDAY(F218)=3;F218+12;
IF(WEEKDAY(F218)=4;F218+13;
IF(WEEKDAY(F218)=5;F218+14;
IF(WEEKDAY(F218)=6;F218+15)))))
In other words:
If startdate = Monday then startdate + 11,
if startdate = Tuesday then startdate + 12, etc.
This works, but I have 300+ rows and dragging this function down doesn't change the cell references.
I know about the NETWORKDAYS and WEEKDAY functions, but I encounter problems with any Monday where only 1 weekend passes and other days where 2 weekends pass.
First of all, I am assuming that your first day - whatever day that may be - is considered day one (1). So in my scenario, if a SLA states 2 days to complete a repair and the start date is a Monday, I'm assuming the repair should be completed by Tuesday.
My assumption is based off this comment by #RonRosenfeld:
...although you might have to subtract 1 from the number of days
With all that being said, try this formula in your cell instead:
 NOTE: You may need to change things like commas and semi-colons to adjust for your region.
=WORKDAY($F2,$G2-1)+LOOKUP(WEEKDAY(WORKDAY($F2,$G2-1),16),{1;2;3},{2;1;0})
What it does:
WORKDAY($F2,$G2-1)
First we want to find out exactly what day the repairs should be completed by if weekend days (Saturday and Sunday) were included. This part of the formula will simply give us a place to start.
$F2 is your repair start date
$G2 is the number of days a repair is supposed to take (you may need to add a column for this, because, as you stated, the SLA may change and you need the formula to be easily adjusted)
WEEKDAY(WORKDAY($F2,$G2-1),16)
The WORKDAY function from above is wrapped inside a WEEKDAY function. This WEEKDAY function is written to account for each day of a week to be assigned numbers. The [return_type] parameter of 16 tells Excel to label them as "Numbers 1 (Saturday) through 7 (Friday)". We chose 16 so that our LOOKUP function is easier to write. This part of the formula only returns a one-digit number, which in turn will be used to figure out what day of the week we actually want when excluding weekends.
LOOKUP(WEEKDAY(WORKDAY($F2,$G2-1),16),{1;2;3},{2;1;0})
We finish the formula by adding the result from a LOOKUP function using the first form of the function: LOOKUP(lookup_value,lookup_vector,[result_vector])
We found our lookup_value in the previous bullet point using the WEEKDAY function. Now we want Excel to use the lookup_vector - {1;2;3} in our formula - to find the correct value to add to the first part of our formula (which is found using the [result_vector] - {2;1;0} in our formula).
The lookup_vector only has three values: 1, 2, and 3.
1 signals Saturday
2 signals Sunday
3 signals all other days
Think of the lookup_vector and [result_vector] as forming a matrix/table from which our value is found:
1   2
2   1
3   0
If our number of repair days pushes us to:
a Saturday (1), the formula adds 2.
a Sunday (2), the formula adds 1.
any weekday, the formula adds 0 (since weekdays are acceptable).
Hopefully all of this makes sense. Best of luck to you!

Excel Formula for calculating time in round numbers with hours text

I'm trying to figure out a way to create an excel spreadsheet that will allow me to keep track of how many hours I've earned per each paid holiday my company offers, then keep track of how many hours I've used and what's remaining. But I'm unsure how to calculate this properly.
I could easily do the math my self as it's a simple lay out, but I'm trying to find a way that will just let me enter the numbers for earned and used and walk away from anything else.
What I'm trying to do is the follow:
Have multiple sections. In the first section it'll be my holidays. So in like Column A, working down I'd have New Years, Memorial Day, July 4th, etc. Column B working down would be time earned. But this would be labeled in each cell as "8 Hrs" or "4 hrs". Column C would be time used in the same format "4 hrs" "8 hrs". Then Column D would simple be hours remaining.
Now in the second section I'd have holiday hours earned, which is 2 weeks. Not too sure how to lay it out, and then I still have my sick days, but not sure if I should include that in section 2 or not with the vacation time.
I'd like a way to be able to simply Calculate B2 - C2 = D2. So 8 Hrs - 4 Hrs = 4 Hrs (to show 4 Hrs remaining for each line item.)
Problem is I'm unsure how to calculate remaining time simply because of the Hrs suffix. And with that I also can't calculate total time still remaining, both for holiday hours earn and vacation/sick hours.
Yes, it's easier for me to track it as 8 Hrs rather than 1 day, etc.
Any advice on how to formulate this. Or if anyone knows of a premade template that fits this type of scenario, that I could then just take and integrate into my own spreadsheet.
Sorry if this is confusing in any way.
Also, As I'm no excel wizard, unsure if this is relevant or not, but I'm using Excel 2016, as part of the Office suite.
Another option is to just leave the number as it is and label the column accordingly. Do you really need to see "hrs" in every cell when you know you are tracking hours?
Use a custom number format of,
[>1]0 \H\r\s;[=1]0 \H\r_);0 \H\r\s;[Red]#
... and treat all hours as integers.

Calculate annual leave between two dates in Excel

This task seems easy enough yet I just can't figure a way of doing this without resorting to vba.
All I need is to know the number of hours an employee has used up on annual leave, based on a start and end date, and their hours of work.
To be more clear, this example shows one employees contracted hours from Monday to Sunday i.e. they work only Weds, Thurs, and Friday, for 7.5 hours each day.
Below shows the start and end date that the employee has chosen to take for annual leave. I need to calculate, based on their contracted hours, how much annual leave is used between the two dates. The answer would be 45 hours in this case.
Here's another approach - I've expanded the days between the start and end dates into an array then used the resulting day numbers to offset into the days of work range
=SUMPRODUCT(N(OFFSET(A3,0,WEEKDAY(ROW(INDIRECT(A6&":"&B6)),2)-1)))
If you had a list of holiday dates somewhere (say in I3:N3) you could exclude them as follows
=SUMPRODUCT(N(OFFSET(A3,0,WEEKDAY(ROW(INDIRECT(A6&":"&B6)),2)-1))*ISNA(MATCH(ROW(INDIRECT(A6&":"&B6)),I3:N3,0)))
- it is a bit long-winded but the only way I can think of at the moment.

Excel Trend Projection

I'm trying to find a trend projection that compares between same week of 2 consecutive years and also from previous weeks of a particular year. What is the excel formula that helps me to do this?
I need to find the projected values for week 15 all the way to week 53 for This year, based on
The previous weeks of This year (Week 1- Week 14) as well as
The same week Last year (Week 15)
You could use the Trend function, setting Known X's to Last Year weeks 1 to 14 and Known Y's to This Year weeks 1 to 14.
Then set the New X's to the same week for last year and the function will use the Least Squares method to extrapolate for this year.
If you use absolute references (e.g. $A$1:$A$10) for the Known X's and Y's, and a relative reference for the New X's, then you can just copy/paste the formula from This Year week 15 down.
Keep in mind though that the further you get from the Known values, the less accurate the forecast becomes...
Are you familiar with the add-in solver or Data Analysis? Sometimes you have to unhide it by going to options>add-in>"Data Analysis" to use it but it does simple analyses. You will find several helpful tools for doing stats in "Data Analysis."

Hours to working days

Where I work I don't get paid overtime, but I accrue holiday days for the overtime I work. I have the following spreadsheet which calculates how much overtime I've done and totals it in D15.
Now I want to calculate how many days this is, based on 8 hours per day. In D16, I've done =D15/8 and formatted it as h.mm \d\a\y\s, but this shows as 2.26 days instead of 2.4375 days.
What is the correct formula to use in D16?
Note to reader: this question led to multiple solutions some of which were discussed in the comments. Here is a summary of the solution found.
First solution
=(HOUR(D15)+MINUTE(D15)/60)/8
Explanation
Dates and time in Excel are stored as serial numbers, so 19:30 is actually 0.8125.
So, if you divide it by 8, you will get 0.1015625.
This latter value is worth 2.26 days
OP's version (thanks to Danny Becket (OP)) - see the comments below.
This solution now handles hours > 24.
=((DAY(D20)*24)+HOUR(D20)+(MINUTE(D20)/60))/8
or better (credits to Barry Houdini):
=((INT(D20)*24)+HOUR(D20)+(MINUTE(D20)/60))/8
The former formula has a limitation for large values, perhaps not relevant here but if D20 is 800:00 then you get the wrong answer (7 days rather than 100 days). This is probably because DAY function is giving you calendar day which will "reset" at 31, best to use INT in place of DAY.
Another easily understandable version
Divide by the length of the day as a time value:
=D15/"8:00"
More easily changed if length of workday changes
Enter:
in B3 8:3
in C3 16:3
in D3 =IF(B3<C3,C3-B3-1/3,2/3-B3+C3)
Select B3:D3, format as hh:mm and copy down as far as required.
Sum ColumnD and append *3 to the formula, but format as Number.
Add data by overwriting cells in ColumnB and/or ColumnC as required (defaults do not add to total).
Copes with overtime up to next regular start time (ie including past midnight, new serial number). 1/3 because standard working day is 8 hours (24 hours is unity for date serial counter). B3 and C3 could be hard coded but (i) there is no need and (ii) allows more flexibility. If to readily identify non standard start/finish could use conditional formatting.
Does not address weekend overtime but could easily be adapted to do so (eg add column, flag weekend day with 8 in that extra column then add that 8 [1/3] to the finish time).
Make sure that D15 has a number format of [h]:mm
then have D16 as =sum(D15/"8:00") should work fine
thats what i have tracking my annual leave, I work 37h pw with a leave day being classed as 7h24m or a half day of leave as "3:42"
I have leave taken as a cumulative figure assigned as [h]:mm in cell K2 of my spreadsheet
then I have K3=SUM(K2/"7:24") for days taken formatted as a general number
you may also need to change the date datum in excel to the 1904 date system http://support.microsoft.com/kb/182247/en-gb
to get this to work (only a problem if you have negative time as I do when calculating flex hours)

Resources