Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Sushil9104
New Member

Month on Month employee Cost based on date of joining and date of exit.

I have data which contains employee cost, Name, Date of joining, Date of exit for last 5 years and the current monthly cost. Want to present in a dashboard pro rata monthly cost based on date of joining and date of exit for each month. Please help as tried many dax formula but not getting the results. 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Sushil9104 ,

Please have a try.

Create a measure.

Pro Rata Monthly Cost = 
VAR CurrentMonth = SELECTEDVALUE ( 'Date'[Month & Year] )
VAR CurrentEmployee = SELECTEDVALUE ( 'Employee'[Name] )
VAR DateOfJoining = CALCULATE ( MIN ( 'Employee'[Date of joining] ), FILTER ( 'Employee', 'Employee'[Name] = CurrentEmployee ) )
VAR DateOfExit = CALCULATE ( MAX ( 'Employee'[Date of exit] ), FILTER ( 'Employee', 'Employee'[Name] = CurrentEmployee ) )
VAR DaysInMonth = DAY ( EOMONTH ( CurrentMonth, 0 ) )
VAR DaysWorked = COUNTROWS ( DATESBETWEEN ( 'Date'[Date], MAX ( DateOfJoining, EOMONTH ( CurrentMonth, -1 ) + 1 ), MIN ( DateOfExit, EOMONTH ( CurrentMonth, 0 ) ) ) )
VAR MonthlyCost = CALCULATE ( SUM ( 'Employee'[Current monthly cost] ), FILTER ( 'Employee', 'Employee'[Name] = CurrentEmployee ) )
RETURN
DIVIDE ( MonthlyCost, DaysInMonth ) * DaysWorked

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Sushil9104 ,

Please have a try.

Create a measure.

Pro Rata Monthly Cost = 
VAR CurrentMonth = SELECTEDVALUE ( 'Date'[Month & Year] )
VAR CurrentEmployee = SELECTEDVALUE ( 'Employee'[Name] )
VAR DateOfJoining = CALCULATE ( MIN ( 'Employee'[Date of joining] ), FILTER ( 'Employee', 'Employee'[Name] = CurrentEmployee ) )
VAR DateOfExit = CALCULATE ( MAX ( 'Employee'[Date of exit] ), FILTER ( 'Employee', 'Employee'[Name] = CurrentEmployee ) )
VAR DaysInMonth = DAY ( EOMONTH ( CurrentMonth, 0 ) )
VAR DaysWorked = COUNTROWS ( DATESBETWEEN ( 'Date'[Date], MAX ( DateOfJoining, EOMONTH ( CurrentMonth, -1 ) + 1 ), MIN ( DateOfExit, EOMONTH ( CurrentMonth, 0 ) ) ) )
VAR MonthlyCost = CALCULATE ( SUM ( 'Employee'[Current monthly cost] ), FILTER ( 'Employee', 'Employee'[Name] = CurrentEmployee ) )
RETURN
DIVIDE ( MonthlyCost, DaysInMonth ) * DaysWorked

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

some_bih
Super User
Super User

Hi @Sushil9104 provide some example data with wanted output as example.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.