Forum Discussion

lg1551's avatar
lg1551
Icon for Resolver II rankResolver II
3 years ago
Solved

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.

  • lg1551's avatar
    lg1551
    3 years ago

    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.

6 Replies

  • AllisonKennedy's avatar
    AllisonKennedy
    Icon for Community Champion rankCommunity Champion

    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

    • lg1551's avatar
      lg1551
      Icon for Resolver II rankResolver II

      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's avatar
        AllisonKennedy
        Icon for Community Champion rankCommunity Champion

        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. 

    • lg1551's avatar
      lg1551
      Icon for Resolver II rankResolver II

      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.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi lg1551 ,

     

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

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

    Below is the solution.

    1.Create a disconnnected calculated table using dax. 

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

    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 )
    )
    

     

    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.           

    • lg1551's avatar
      lg1551
      Icon for Resolver II rankResolver II

      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.