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
lg1551
Resolver II
Resolver II

Use a Default Measure When Slicer is Set to 'All'

I have a Quarter/Month Hierarchy Slicer.

 

By Default, the slicer is set to "All", meaning nothing is selected in the slicer. When it is in this state, I want the visual to display a specific measure.

 

If the user selects a Month or Quarter from the slicer or multiple Months or Quarters, I want it to use a different measure.

 

I've tried, SELECTED VALUE, HASONEFILTER, HASONEVALUE,and ISFILTERED. 

 

But it seems Power BI thinks the slicer is in fact filtered, when nothing is selected.

 

What I'm looking for is a default visual display when nothing is selected, but the visual can be customized as the user selects Quarters or Months.

 

Thank you.

1 ACCEPTED SOLUTION

Thanks for the reply. I was actually able to get this sorted out. 

 

What I was after, was for the visual to use a default measure, when the slicer has nothing or "All" selected. I was able to achieve this via some DAX.

View solution in original post

6 REPLIES 6
v-stephen-msft
Community Support
Community Support

Hi @lg1551 ,

 

When you want the slicer not to select a month or quarter, the visual is empty, such as the following.

vstephenmsft_0-1675925262760.png

When there's a selection in the slicer, display specific results in the table visual.

vstephenmsft_1-1675925293817.png

Below is the solution.

1.Create a disconnnected calculated table using dax. 

vstephenmsft_2-1675925367217.png

2.The fields of the slicer are from Table 2.

vstephenmsft_3-1675925432242.png

3.Create measure as the visual-level filter. Put it into the table visual and set up show items when the value is 1. And then the expected you want is done.

 

Measure =
IF (
    ISFILTERED ( 'Table 2'[Quarter] ) || ISFILTERED ( 'Table 2'[Month] ),
    IF ( MAX ( 'Table'[Month] ) IN ALLSELECTED ( 'Table 2'[Month] ), 1 )
)

 

16.png

The key is to create a disconnected table.

You can download my attachment for more details.

 

Best Regards,

Stephen Tao

 

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

Thanks for the reply. I was actually able to get this sorted out. 

 

What I was after, was for the visual to use a default measure, when the slicer has nothing or "All" selected. I was able to achieve this via some DAX.

AllisonKennedy
Super User
Super User

@lg1551 

 

You need to determine how many values the slicer has without filters, then compare to how many it has in current context:

 

Measure = 
VAR _CountAllOptions = CALCULATE( countrows( values ( table[column] ) ), ALL() )

VAR _CountCurrentOptions = countrows( values ( table[column] ) )

VAR _Result = IF( _CountAllOptions = _CountCurrentOptions, [Default Measure], [Other Measure] )


RETURN
_Result


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

I had the original measure and I created 2 additional measures.

 

Measure 1: This measure displays the data as I want it displayed in default state (no slicer selection).

Measure 2: This is a measure that uses an IF statement. If(selectedvalue('slicer')=Blank(), Measure 1, Original Measure.

Thanks for the reply. I was actually able to get this sorted out. 

 

What I was after, was for the visual to use a default measure, when the slicer has nothing or "All" selected. I was able to achieve this via some DAX.

@lg1551  Can you please share the DAX that you've used so others can benefit? I'd also be interested to learn how it differs from the DAX I suggested to you. 

 

Thanks! and glad you got it solved. 


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

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.