How to calculate workdays and compensation for given period based on Employee's monthly salary? - excel

I have only three editable fields:
salary = 15,000
start date = 18 Jul 2014
end date = 12 Oct 2014
With these fields, I need to calculate the total salary I need to pay. Payment is on a monthly basis:
(JULY = 15,000 / 31 * 14) +
(AUG = 15,000 / 31 * 31) +
(SEPT = 15,000 / 30 * 30) +
(OCT = 15,000 / 30 * 12).
I can get total days based on both dates (ie 87 days, =DAYS($enddate,$startdate)+1) ) but I need to split the days according to the months.
What formula do I need automatically to get the amount, because each person will have different salary and different dates?

You can use Excel VBA custom Function to solve your problem:
1). First, you should populate Excel Worksheet with data structure reflecting Employees Name, Monthly Salary, StartDate and EndDate, like in the following sample:
Employee M.Salary Start Date EndDate
John $15,000.00 7/18/2014 10/12/2014
Ann $20,000.00 7/19/2014 10/13/2014
Peter $16,000.00 7/20/2014 10/14/2014
Jeff $25,000.00 7/21/2014 10/15/2014
2). The DAYS in date range can be simply found by subtraction (EndDate-StartDate), because the underlying data type in integer
3). For general solution to the problem (Calculate the compensation for any arbitrary period and monthly salary) you will need to create custom VBA formula and use it in a separate column for each Employee. Refer to this article for explanation: Create a custom worksheet function in Excel VBA
4). Pertinent to your particular case with fixed date rage, the simplified solution based on the Excel Worksheet formulas (no VBA) is described below:
Employee MoSalary Start End Days FullMo FirstMo LastMo Total
John $15,000.00 7/18/2014 10/12/2014 87 30000.00 $6,774.19 $6,000.00 $42,774.19
Ann $20,000.00 7/18/2014 10/12/2014 87 40000.00 $9,032.26 $8,000.00 $57,032.26
Peter $16,000.00 7/18/2014 10/12/2014 87 32000.00 $7,225.81 $6,400.00 $45,625.81
Jeff $25,000.00 7/18/2014 10/12/2014 87 50000.00 $11,290.32 $10,000.00 $71,290.32
4a). In column E starting with row 2 add formula for DAYS : =(D2-C2)+1 and extend it for entire range
4b). In column F starting with row 2 add formula for whole months : =2*B2 and extend it for entire range
4c). In column G starting with row 2 add formula for the first month : =14*B2/31 and extend it for entire range
4d). In column H starting with row 2 add formula for last month : =12*B2/30 and extend it for entire range
4e). In column I starting with row 2 add formula for total compensation : =SUM(F2:H2) and extend it for entire range
Hope this will help. Best regards,

I have split this out because I am not entirely sure what you require and you may be able to assemble the pieces in a way that better suits you:
Assuming your data is in A1:A3, put 1/7/14 in C1, 1/8/14 in D1, 1/9/14 in E1 and 1/10/14 in F1.
To count the number of applicable days by month, in C2 enter:
=IF(MONTH($A2)=MONTH(C1),EOMONTH(C1,0)-$A2+1,IF(MONTH($A3)=MONTH(C1),DAY($A3),EOMONTH(C1,0)-EOMONTH(C1,-1)))
To compute the salary for the month by computing the daily rate for the applicable month and multiplying that by the number of days from above, in C3 enter:
=$A1*C2/(DAYS(EOMONTH(C1,0),C1)+1)
Format C2:C3 to suit and copy across to F2:F3.

Related

Excel - How to do the following?

I have a question related to EXCEL:
Since I have the following prices for different period, how can I compute in an automatic way, for example the price between 10 June - 15 July ?
EDIT--> Expected output:
50€+50€ (10-11 june) + 58€x13 (period 12 june - 25 June) + 75€x13 (period 26 june - 9 July) + 92€x5 (period 10 july-15july) = 2289€
This is the same pictures with the cells in excel, please do not consider the "Price of period", but only the daily price
You could do this with a (lengthy) calculation:
Consider:
A8 Contains the from date (10-06-2021)
B8 Contains the from date (17-07-2021)
=(MIN($B$8,D3)-MAX($A$8,C3)+1)*C5+(MIN($B$8,F3)-MAX($A$8,E3)+1)*E5+(MIN($B$8,H3)-MAX($A$8,G3)+1)*G5+(MIN($B$8,J3)-MAX($A$8,I3)+1)*I5
This will consider a period from 10-06 - 11-06 a period of 2 days. And also 12-06 - 25-06 a period of 14 days, and so on.
The result is: 2514.00
One method would be to create a lookup table and use a formula.
Given your data, your lookup table might as shown below:
I NAME'd it: priceTable
You can then use the formula:
=SUM(VLOOKUP(SEQUENCE(End-Start+1,,Start,1),priceTable,2))
If, for some reason, you cannot easily create priceTable, you can create it with a formula (depending on your version of Excel):
=INDEX($C$4:$I$6,{1,3},{1;3;5;7})
Note: All of the formulas assume your dates are real dates and not strings.
If your version of Excel does not have the SEQUENCE function, you can replace it with:
=SUM(VLOOKUP(ROW(INDEX($A:$A,Start):INDEX($A:$A,End)),priceTable,2))

Week number based on Date

I need to make week number based on given date.
Today 28-08-18
Week .....
30-07-18 1
06-08-18 2
13-08-18 3
20-08-18 4
27-08-18 5
03-09-18 6
10-09-18 7
17-09-18 8
24-09-18 9
01-10-18 10
08-10-18 11
15-10-18 12
22-10-18 13
29-10-18 14
I want the cell next to "week" to be based on today's date.
Assuming 30-07-18 is located # A1. in B1, type in :
=WEEKNUM(A1,2)-WEEKNUM($A$1,2)+1
and drag it down. Glad that you'd tried. ( :
All the best.
Start by inserting a date in any cell, that will be the first week.
Create a function that calculates the difference between its adjacent
cell and the first and divides it by 7. Voilà you've got the week number. You can round it if you want.
The formula is as follows: Floor((First date - Current date)/7).
Useful link for subtraction: http://www.theexceladdict.com/_t/t040303.htm.
Good luck,
Alex
Your base date (BD) may not be the start of the week (SOW), so the general solution could be
calculate the SOW from your base date: SOW = BD - WEEKDAY(BD)+2
calculate the distance DI from given date (GD) to SOW: DI = GD - SOW
convert distance into weeknumber W = INT(DI/7)
EDIT:
SOW = IF(WEEKDAY(BD)=1;BD-6;BD-WEEKDAY(BD)+2)
this is to cover cases where BD is a Sunday and SOW should be the Monday before (not after)

Retutn only Buisness days in custom date function in excel

I have a date which I will need to increment the date by a day, month or year from the actual date. This is based of a list of fields below and is different per the input. Also each resultant date has to be a business day i.e not a weekend day or a bank holiday. Also if the resultant date is either Dec 25 or Jan 1st the day needs to move forward to the next business day (not a weekend day).
I have created this in Excel using a couple of formulas though it is a bit clunky.
Below is my data set
Business Date 15/05/2018
Tenor Settlement Value Settlement Period
ON 1 Day
TN 2 Day
SP 2 Day
SN 3 Day
1W 7 Day
2W 14 Day
3W 21 Day
1M 1 Month
2M 2 Month
3M 3 Month
In column E - I am using formula
=IF(D4="Day",$B$1+C4,IF(D4="Month",EDATE($B$1,C4),(TEXT($B$1,"dd/mm/")&(YEAR($B$1)+C4))+0))
In column F - I am using formula
=E4+LOOKUP(WEEKDAY(E4),{1,2,3,4,5,6,7},{1,0,0,0,0,0,2})
In column G - I am using formula
=F4+IF(AND(OR(TEXT(F4,"ddmm")="2512",TEXT(F4,"ddmm")="0101"),WEEKDAY(F4)>=2,WEEKDAY(F4)<=6),LOOKUP(WEEKDAY(F4),{1,2,3,4,5,6,7},{0,1,1,1,1,3,0}),LOOKUP(WEEKDAY(F4),{1,2,3,4,5,6,7},{1,0,0,0,0,0,2}))
In H I format the date in mm/dd/yyyy and I have my desired result.
storax has kindly created a function for me which replicates my excel formula in column E - on this thread Increment a date by a number of days, months or years
Function IncDate(ByVal dt As Date, ByVal add As Long, ByVal dmy As String) As Date
Select Case UCase(dmy)
Case "DAY"
IncDate = DateAdd("d", add, dt)
Case "MONTH"
IncDate = DateAdd("m", add, dt)
Case "YEAR"
IncDate = DateAdd("yyyy", add, dt)
Case Else
IncDate = dt
End Select
Could use some advise on how I could incorporate my formulas in columns F & G to make the process less clunky.
Manipulating the DATE function (DateSerial in vba) with the WORKDAY.INTL function seems to produce the correct business dates.
Put this in E4 and fill down.
=WORKDAY.INTL(DATE(YEAR(B$1)+(D4="year")*C4, MONTH(B$1)+(D4="month")*C4, DAY(B$1)+(D4="day")*C4)-1, 1, 1, holidays)
[holidays] is a named range (Formulas, Defined Names, Defined Name) with a Refers To: of,
=Sheet10!$Z$2:INDEX(Sheet10!$Z:$Z, MATCH(1E+99, Sheet10!$Z:$Z))

SLA COUNT IN EXCEL FORMULA

I'm looking for an excel (Office 2016 packet) formula that count SLA for ticket resolution.
the SLA counter must consider :
1) Monday To Saturday as work day ;
2) Holiday as no working days (must be skipeed as work day);
3) SLA start for ticket generate in workdays during range-time "08:00-20:00" out of this time-range SLA count is "0" ;
4) Output should result as R1= first 24Hours ; R2= from 25 to 48 hours ; R3= from 49 to 72 hours; "Out of Sla" = since 72 hours
Data to count SLA is formatted as below for either for ticket open and closure:
Column N Column O Column P Column Q
"TICKET START DATE" "TICKET STOP DATE" "SLA" "HOLIDAY"
28/4/18 13:30 30/4/18 19:20 2 25/04/2018
28/4/18 13:11 29/4/18 13:11 1 01/05/2018
28/4/18 12:57 28/4/18 12:57 1
I solved point 1) & 2) with NETWORKDAYS.INTL formula using the first column as start_date ; the second column as end_date; 11 as third formula's field to exclude Sunday as workdays; fourth formula's value pointing a column where are listed the "holidays" date .
I could not find a solution for point 3).
It will also appreciate a possible solution for point 4) .
Thank you in advance.
Formula example of above fields :
=NETWORKDAYS.INTL(N15;O15;11;Q16:Q17)
Alessandro.
I've needed to do something similar in the past. Please see the formula below. It will give you the amount of time between working days (Monday-Friday), only taking into account times 8:30am to 5:30pm. Try inserting your specific parameters.
=IFERROR((NETWORKDAYS.INTL(H8,I8,,)-1)*("17:30"-"8:30")
+IF(NETWORKDAYS.INTL(I8,I8,,),MEDIAN(MOD(I8,1),"8:30","17:30")
,"17:30")-MEDIAN(NETWORKDAYS.INTL(H8,H8,,)*MOD(H8,1),"8:30","17:30"),"")
H8 = Start Date
I8 = End Date
8:30 = Start Time
17:30 = End Time

MS Excel: Using AGGREGATE to add up all mileage in each month

I have the following data in a logbook format:
DATE MILEAGE
02-Jul-13 15
05-Jul-13 12
09-Jul-13 156
10-Aug-13 20
11-Aug-13 20
12-Aug-13 232
12-Aug-13 20
13-Aug-13 265
15-Aug-13 20
18-Aug-13 20
I am looking to extract data from it.
I need to ignore errors and #N/A so I have been trying to use the AGGREGATE function. To no avail though.
I would like to present the following information:
Mileage this month -
=AGGREGATE(9,7, IF(MONTH(IFERROR(LogBookTable[Date], 0)) = MONTH(TODAY()), LogBookTable[Total KM], 0)) - Does not work
Mileage in July -
=AGGREGATE(9,7, IF(MONTH(IFERROR(LogBookTable[Date], 0)) = MONTH(7), LogBookTable[Total KM], 0)) - Does not work
Mileage in August -
=AGGREGATE(9,7, IF(MONTH(IFERROR(LogBookTable[Date], 0)) = MONTH(8), LogBookTable[Total KM], 0)) - Does not work
Total Mileage -
=AGGREGATE(9,7,LogBookTable[Total KM]) - This works
The monthly mileage and current month mileage all result in a "#VALUE!" being displayed.
Any assistance would be much appreciated.
Just in case anyone asks, the naming schemes are corrected, it's not the references that aren't working, it's the values.
You could use DSUM. If you had two criteria cells setup Say in D1:E2 as follows:
Date Date
>1/07/2013 <31/7/2013
and if your data was in A1:B11 (as per your example above), to return a sum for July ignoring errors, use the following formula:
=DSUM(A1:B11,2,D1:E2)
You could setup the criteria such that they were updated based on the current month, and that the month end is calculated using:
="<"& DATE(YEAR(TODAY()),MONTH(TODAY())+1,DAY(1)-1)
and the month start calculated by:
=">"& DATE(YEAR(TODAY()),MONTH(TODAY()),DAY(1))
Remember that with criteria, multiple criteria on the same row is an AND, and multiple rows on the same criteria is an OR.
You can use SUMIF is you add a column representing the month of the date:
Column B contains =MONTH of Column A. All you have to do is update the DATE entry in A16 with a new date. B16 is accordingly updated with the appropriate month, creating a new monthly aggregate/sum.

Resources