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
cmilligan262
Helper II
Helper II

Help with measure working with slicer

I have multiple slicers in one of my visuals. If I select a value from one slicer it filters the other slicers to only show valid options to select. 

 

The problem is that I have a measure that I have to calculate a percentage and to do that I have to bypass one of the slicers.

 

I use ALL() in the filter of a calculate expression but it by passes all one of my other slicers.

 

I know this is a little vauge so let me know what other information is needed to get past this.

 

Thank you.

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @cmilligan262 

 

Based on your description, you may try to use 'Allselected'. I created data as follows.

e1.png

 

You may create two measures and compare the results to have a better understanding of them.

 

 

PercantageAllselect = 
DIVIDE(
    SUM('Table'[Score]),
    CALCULATE(
        SUM('Table'[Score]),
        ALLSELECTED('Table')
    )
)

PercentageAll = 
DIVIDE(
    SUM('Table'[Score]),
    CALCULATE(
        SUM('Table'[Score]),
        ALL('Table')
    )
)

 

 

 

When there is no slicer selected, the result of two measures are the same.

e2.png

 

When you select 'c1' to filter the result, the results differ.

e3.png

 

The denominator of 'PercentageAllselect' is calculated by (88+94), while the denominator of 'PercentageAll' is calculated by (82+91+88+69+76+94). 

 

ALL is a useful function that returns all the rows of a table or all the values of a column, depending on the parameter you use. What you need here is a function that does not return all of the scores, but only the ones selected in the original filter context, that is, the one of the complete pivot table. We call this kind of  computation Visual Totals, because it uses as the grand total that is visible to the user instead of the total of the complete data model. The function to use here is ALLSELECTED. 

 

For further information, you may refer to the following links.

https://docs.microsoft.com/en-us/dax/all-function-dax

https://docs.microsoft.com/en-us/dax/allselected-function-dax

 

Best Regards

Allan

 

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

1 REPLY 1
v-alq-msft
Community Support
Community Support

Hi, @cmilligan262 

 

Based on your description, you may try to use 'Allselected'. I created data as follows.

e1.png

 

You may create two measures and compare the results to have a better understanding of them.

 

 

PercantageAllselect = 
DIVIDE(
    SUM('Table'[Score]),
    CALCULATE(
        SUM('Table'[Score]),
        ALLSELECTED('Table')
    )
)

PercentageAll = 
DIVIDE(
    SUM('Table'[Score]),
    CALCULATE(
        SUM('Table'[Score]),
        ALL('Table')
    )
)

 

 

 

When there is no slicer selected, the result of two measures are the same.

e2.png

 

When you select 'c1' to filter the result, the results differ.

e3.png

 

The denominator of 'PercentageAllselect' is calculated by (88+94), while the denominator of 'PercentageAll' is calculated by (82+91+88+69+76+94). 

 

ALL is a useful function that returns all the rows of a table or all the values of a column, depending on the parameter you use. What you need here is a function that does not return all of the scores, but only the ones selected in the original filter context, that is, the one of the complete pivot table. We call this kind of  computation Visual Totals, because it uses as the grand total that is visible to the user instead of the total of the complete data model. The function to use here is ALLSELECTED. 

 

For further information, you may refer to the following links.

https://docs.microsoft.com/en-us/dax/all-function-dax

https://docs.microsoft.com/en-us/dax/allselected-function-dax

 

Best Regards

Allan

 

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

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.