Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
JMSNYC
Helper III
Helper III

Different Measures Displayed if Filter is selected or not

Hi and Happy New Year 2024 to the Community.

 

Here is my issue: I want to display a bar chart with 2023 values

1- if the "Year" filter does not have any selection, display chart using Measure #1 (only 2023 values)

2- if the "Year" filter has a selected valye, than use Measure #2 (values conditioned by filter selection)

 

Thank you for your help.

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @JMSNYC 

Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.

 

vyaningymsft_0-1704878004839.png

 

vyaningymsft_1-1704878004840.png

 

Measures:

 

AppearDataByYear =

VAR _slicer_count =

    DISTINCTCOUNT ( 'Slicer'[Year] ) 

VAR _all_count =

    COUNTROWS ( ALL ( 'Slicer' ) ) 

VAR _selcet_years =

    ALLSELECTED ( 'Slicer'[Year] ) 

VAR _max_year =

    CALCULATE ( MAX ( 'Table'[Year] ), ALL () ) 

VAR _filter =

    SWITCH (

        TRUE (),

        _slicer_count = _all_count, IF ( SELECTEDVALUE ( 'Table'[Year] ) = _max_year, 1 ),

        _slicer_count < _all_count, IF ( SELECTEDVALUE ( 'Table'[Year] ) IN _selcet_years, 1 ) 

    )

RETURN

    _filter

 

 

If this does not work, could you please share some sample data without sensitive information and expected output.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi, @JMSNYC 

Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.

 

vyaningymsft_0-1704878004839.png

 

vyaningymsft_1-1704878004840.png

 

Measures:

 

AppearDataByYear =

VAR _slicer_count =

    DISTINCTCOUNT ( 'Slicer'[Year] ) 

VAR _all_count =

    COUNTROWS ( ALL ( 'Slicer' ) ) 

VAR _selcet_years =

    ALLSELECTED ( 'Slicer'[Year] ) 

VAR _max_year =

    CALCULATE ( MAX ( 'Table'[Year] ), ALL () ) 

VAR _filter =

    SWITCH (

        TRUE (),

        _slicer_count = _all_count, IF ( SELECTEDVALUE ( 'Table'[Year] ) = _max_year, 1 ),

        _slicer_count < _all_count, IF ( SELECTEDVALUE ( 'Table'[Year] ) IN _selcet_years, 1 ) 

    )

RETURN

    _filter

 

 

If this does not work, could you please share some sample data without sensitive information and expected output.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.