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 measure based on multiple slicers

Hi - 

 

I have what should be a super simple problem.

 

Data example:

 

PersonHours_WorkedDay_Week

A

5Monday
B10Monday
A5Tuesday
C12Monday

 

 

I have multiple slicers, one for Person and one for Day_week

 

Example1 - Day_Week slicer set to 'All' , Person slicer set to 'A' - I want to return 10 for 'Hours_Worked

Example2 - Day_Week slicer set to 'Monday' , Person slicer set to 'A' - I want to return 5 for 'Hours_Worked

 

Currently using: MeasureName = calculate(sum(tableName[Hours_Worked], ALLEXCEPT(TableName,TableName(Person))

 

The above measure returns the correct sum of hours by person, but doesnt update when the Day_week slicer is used.

 

PLEASE HELP!

 

7 REPLIES 7
amitchandak
Super User
Super User

@Anonymous ,

Your requirement should be done with

= calculate(sum(tableName[Hours_Worked])), Not sure on the need of all except

 

Also refer this :https://www.sqlbi.com/articles/managing-all-functions-in-dax-all-allselected-allnoblankrow-allexcept/

Anonymous
Not applicable

Thanks - but I need to return the following when 'All' is selected:

 

PersonHours_WorkedDay_Week

A

10Monday
A10Tuesday

 

and the following when a single day (i.e., monday) is selected:

 

PersonHours_WorkedDay_Week

A

5Monday

 

Reason beig that I need to use this measure in a conditional formatting rule to highligh when hours go above a certain level

Anonymous
Not applicable

Hey @Anonymous ,

 

Try Using 

 

calculate(sum(tableName[Hours_Worked], ALLEXCEPT(TableName,TableName[Person], ALL(TableName,TableName[Day_Week])

 

This will give you the sum of Hours for all days (irrespective of what Day you choose in the slicer) for each Person.

 

Hope this helps!

@AnonymousWith the table that @Anonymous has, your query will have same result as @amitchandak's query. Correct me if I am wrong.

 

@Anonymous  I don't think it is possible to do what you are asking with one single metric. For Power BI, it doesn't matter if it's a slicer or a line item in a row. If the measure definition needs it to slice across a value (Day_of_Week in this case), it will slice across it. You can probably have one measure that calculates the Total hours irrespective of the Day_of_Week and one that calculates a regular SUM. Please let us know if you have found a way to achieve this with one measure.

Anonymous
Not applicable

@karun_r hmm, perhaps i'm not explaining clearly-

 

What i'm trying to do is no different than getting the sum of work days, by person and by weekday- in a dynamic fashion - when a slicer is selected

I am quite not sure on what you mean by dynamically here. Maybe an example diagram in Excel ?

Anonymous
Not applicable

dynamic as in, the sum of hours changes based on what's selected within the slicer

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