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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
narangaman
New Member

Calculate cost based on date range and percentage allocation

Hi , I am trying to calculate montly cost spend for a Project (with some employees) from a Program level timesheet data. I have two tables

  • one with timesheet entered each day for the last couple of years by every employee in the program (in hours) each day
  • Other with employee day rate (per day (8 hour day)) between start date and end date and their percentage allocation between those start and end dates.

Table 1 (program level data) Ex

Employee UsernameBilled HoursDate

A

84-jan-23
B64-jan-23
C46-jan-23

A

55-jan-23
B45-jan-23
D24-jan-23
E47-jan-24

F

18-jan-24
A19-jan-24
B67-jan-24

 

Table 2 (project level data)

 

Employee Usernamestart dateend dateday ratepercentage allocation
A1-jan-235-jun-2310050%
A6-jun-2331-dec-23200100%
A1-jan-244-mar-2430060%
B1-jan-235-jun-23100100%
B6-jun-2331-dec-23200100%
C6-jun-2331-dec-2340020%
C1-jan-244-mar-24500

50%

 

I want to create views where i can show cost per month ( for project level ( only A,B and C) employees) 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Here's one way.  In Table 1, write this calculated column formula to bring over the per day rate from Table 2

Per day rate = calculate(sum('Table 2'[day rate]),fiter('Table 2','Table 2'[Employee username]=earlier('Table 1'[Employee Username])&&'Table 2'[Start date]<=earlier('Table 1'[Date])&&'Table 2'[End date]<=earlier('Table 1'[Date])))

Similarly, bring over the percentage allocation column as well.  Effectively, Table 1 is the only relevant table now.  Next, build a Calendar Table with calculated column formulas for Year, Month name and Month number.  Sort the Month name column by the Month number column.  Create a relationship (many to one and single) from the Date column of Table 1 to the Date column of the Calendar Table.  To your visuals/filters/slicers, drag any date dimension from the Calendar Table.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

1 REPLY 1
Ashish_Mathur
Super User
Super User

Hi,

Here's one way.  In Table 1, write this calculated column formula to bring over the per day rate from Table 2

Per day rate = calculate(sum('Table 2'[day rate]),fiter('Table 2','Table 2'[Employee username]=earlier('Table 1'[Employee Username])&&'Table 2'[Start date]<=earlier('Table 1'[Date])&&'Table 2'[End date]<=earlier('Table 1'[Date])))

Similarly, bring over the percentage allocation column as well.  Effectively, Table 1 is the only relevant table now.  Next, build a Calendar Table with calculated column formulas for Year, Month name and Month number.  Sort the Month name column by the Month number column.  Create a relationship (many to one and single) from the Date column of Table 1 to the Date column of the Calendar Table.  To your visuals/filters/slicers, drag any date dimension from the Calendar Table.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.