Day function & Excel calc time

vijaymehta

New Member
Joined
Apr 3, 2010
Messages
14
Office Version
  1. 365
Platform
  1. Windows
Hi all, I have small projection worksheet which calculates monthly employee cost based out of his start date / end date combination. This ensures I have right cost projection based on expected start/end date, but as data increases, I see noticeable increase in calculation time, which slows down worksheet for any change in date.

I was wondering if there is any better solution to this instead of nested if's and day function.

Thanks in advance.

EmpCost.xlsx
BCDEFGHIJKLMNOPQ
131-Dec-2131-Jan-2228-Feb-2231-Mar-2230-Apr-2231-May-2230-Jun-2231-Jul-2231-Aug-2230-Sep-2231-Oct-2230-Nov-2231-Dec-22
2
3NAME Salary START DATEEND DATEJan-22 AFeb-22 FMar-22 FApr-22 FMay-22 FJun-22 FJul-22 FAug-22 FSep-22 FOct-22 FNov-22 FDec-22 F
4Employee 150,0003/15/20229/28/2022--2,2854,1674,1674,1674,1674,1673,889---
Employee Expenses
Cell Formulas
RangeFormula
F4:Q4F4=IF(AND($D4<=E$1+1,$E4>=F$1),$C4/12, IF(AND($D4<=F$1,$D4>E$1+1,$E4>=F$1),(DAY(F$1)-DAY($D4)+1)/DAY(F$1)*$C4/12, IF(AND($D4<=E$1,$E4>E$1,$E4<F$1),(DAY($E4))/DAY(F$1)*$C4/12, IF(AND($D4>E$1,$E4<F$1),(DAY($E4)-DAY($D4)+1)/DAY(F$1)*$C4/12,0))))
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Pl change the dates E1:R1 as 1-jan 22, 1-feb 22, 1 mar 22...........etc
In F4 copied across

=MAX(0,MEDIAN(F$1-1,EOMONTH(F$1,0),$E4)-MEDIAN(F$1-1,EOMONTH(F$1,0),$D4-1))*($C4/($E4-$D4+1))

50000, I have treated amount for the duration bet ween D4 and E4. So i have divided amount by number of days E4-D4. I don't know 50000 for how many days. If it is for one year Formula should be as below.
In F4
=MAX(0,MEDIAN(F$1-1,EOMONTH(F$1,0),$E4)-MEDIAN(F$1-1,EOMONTH(F$1,0),$D4-1))*($C4/(EOMONTH($Q$1,0)-$F$1+1))
 
Upvote 0
Thank you Srinivas. Yes, 50000 is annual amount. I should have kept USD :)

However, I am somehow getting different monthly amount, like month with 31 days vis-a-vis month with 30 days. This being annual salary, in case of full month, it will be constant and not based on number of days. Any fix for that?
 
Last edited:
Upvote 0
For the whole month it is ok. What about few days in a month . what amount is for few days.
Seem to be off for part month too. Here's snapshot of comparison:
 

Attachments

  • Capture.PNG
    Capture.PNG
    17.7 KB · Views: 11
Upvote 0
IN F4

=IF(AND($D4<=F$1,$E4>=EOMONTH(F$1,0)),$C4/12,MAX(0,MEDIAN(F$1-1,EOMONTH(F$1,0),$E4)-MEDIAN(F$1-1,EOMONTH(F$1,0),$D4-1))*($C4/(12*DAY((EOMONTH(F$1,0))))))
 
Upvote 0
Solution

Forum statistics

Threads
1,223,887
Messages
6,175,199
Members
452,617
Latest member
Narendra Babu D

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top