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
Anonymous
Not applicable

Dynamic table calculations based on slicer

I have a relatively simple summarised table in PowerBI relating to working hours by employees. See below.

 

Table.JPG

The table is a simple summary of Duration Hours and Billable Hours by User, and I'm using a Slicer to choose a required date range. There is also an additional Slicer to choose the Team. i.e. TeamA/TeamB/TeamC etc

 

Unfortunately, I'm having a problem creating '%BillableHours' column in the above for each individual User, and I have no idea where to start. I tried creating the following measure but without any luck...

 

Billable% = DIVIDE (SUM(tblTime[BillableHours]), SUM(tblTime[DurationHours]))

 

I think it needs to be modified to take into account the changing User, but I don't know how to do this. Any help greatly appreciated.

1 ACCEPTED SOLUTION
prakash_gautam
Resolver II
Resolver II

If you simply create a calculated field (measure) instead of a calculated column, your formula should work:

 

Billable% = DIVIDE (SUM(tblTime[BillableHours]), SUM(tblTime[DurationHours]))

 

If you want a calculated column for any reason, this should work:

 

Billable% =
CALCULATE (
SUM ( tblTime[BillableHours] ),
FILTER ( tblTime, tblTime[User] = EARLIER ( tblTime[User] ) )
)

 

you can also add a AND condition if you want in the above formula as:

 

&& tblTime[Team] = EARLIER ( tblTime[Team]) 

 

Thanks

 

View solution in original post

2 REPLIES 2
prakash_gautam
Resolver II
Resolver II

If you simply create a calculated field (measure) instead of a calculated column, your formula should work:

 

Billable% = DIVIDE (SUM(tblTime[BillableHours]), SUM(tblTime[DurationHours]))

 

If you want a calculated column for any reason, this should work:

 

Billable% =
CALCULATE (
SUM ( tblTime[BillableHours] ),
FILTER ( tblTime, tblTime[User] = EARLIER ( tblTime[User] ) )
)

 

you can also add a AND condition if you want in the above formula as:

 

&& tblTime[Team] = EARLIER ( tblTime[Team]) 

 

Thanks

 

Anonymous
Not applicable

Thanks Prakash!

 

Somehow I'd created a calculated column and not a measure. I'll go and pour some coffee in my eyes now...

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.

Top Solution Authors