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
Applicable88
Impactful Individual
Impactful Individual

Change measure calculation base on category selection

Hi,

 

I have a bar chart, with a typical datetable and the sum of duration of workload with following measure:

Workload =

(DIVIDE(CALCULATE(SUMX('Table','Table'[Duration]),24))
Its basically the workload percentage for one day.
 
Unfortunately when I just want to see the workload for one or two shifts after the selection of a shift category, to get the right values it should divide with 8 or respectively 16 hours, not 24 hours anymore. 
Help is much appreciated.
Thank you very much in advanced.
Best.
 
 
1 ACCEPTED SOLUTION
AllisonKennedy
Super User
Super User

@Applicable88 

I think a DimShift or DimTime table might help here, but we need a bit more detail on how you want the 24 to change. 

 

Could you add the denominator info to your Shift table? For example 

 

Shift Category Hours
A 8
B 8
C 8

 

Then divide by SUM(Shift[Hours]) 

 

If all shifts are selected it will divide by 24, if just 2 then 16, if just one, then 8. 

 

Not sure if your model is that simple? Let us know more details if this doesn't work or make sense.


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

2 REPLIES 2
AllisonKennedy
Super User
Super User

@Applicable88 

I think a DimShift or DimTime table might help here, but we need a bit more detail on how you want the 24 to change. 

 

Could you add the denominator info to your Shift table? For example 

 

Shift Category Hours
A 8
B 8
C 8

 

Then divide by SUM(Shift[Hours]) 

 

If all shifts are selected it will divide by 24, if just 2 then 16, if just one, then 8. 

 

Not sure if your model is that simple? Let us know more details if this doesn't work or make sense.


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

@AllisonKennedy indeed a very straightforward approach. I thought too complicated and my approach would only work for selecting one Shiftcategory at a time or all, but not when I'm selecting two: 

 

WorkloadPerDay= DIVIDE(CALCULATE(SUMX('Table','Table '[Duration])),24)))
 
WorkloadPerEachCategory= DIVIDE(CALCULATE(SUMX('Table','Table '[Duration])),8)))
 
AuslastungProTagDynamicShift =

IF(HASONEFILTER('Table'[Shiftcategory]),
SWITCH(SELECTEDVALUE('Tble)'[Shiftcategory]),
"A", [WorkloadPerEachCategory],
"B", [WorkloadPerEachCategory],
"C", [WorkloadPerEachCategory]
),
([WorkloadPerDay])
)
 
Thanks again.
Best regards. 

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.