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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Powers
Helper I
Helper I

how to show productnames in the x-axis based on selected flag slicer

Hi Experts,

I am facing a challenge in one of the scenario, the scenario is I have a isBeverage slicer and it has 2 values 0 and 1. If user selects 0 then data should show totals for 0 and in the x-axis it should show selectedvalue(0) respective productnames in the x-axis. Similarly, If user selects 1 then data should show totals for 0 and 1 productnames and similarly in the x-axis it should both 0 value products and selectedvalue (1) product values. I have created a measure and I am able to get the values and x-axis values for selectedvalue =0 but when I select 1 then I am not getting expected result.

 

Below is my sample dataset

ProductnameSales AmountIsBeverage
Car81510540
Bi-Cycle3594260
Bike5599300
Ship4831670
Bus533510
Cool drinks9635521
Cookies7500921
Chocolates5368571
Chips859371

 

Requirement:
I have IsBeverage slicer in the report and have clustered column chart in the report. In the below chart, I have selected 0 and the chart is getting filtered based on the selected value and it's showing productnames based on selected value.

Powers_0-1724775997216.png

But where as in the 2nd chart, If select 1 then I want to get both 0 and 1 productnames in the x-axis, which I am not able get it.

Powers_1-1724776150854.png

My required output is, If I select 1 then both 0 and 1 productnames should display in the x-axis and it's values. Please see the below expected chart.

Powers_2-1724776271613.png

 

Below is the measure which I have created for this chart

Isproduct = IF(SELECTEDVALUE(Sheet1[IsBeverage])=1,CALCULATE(SUM(Sheet1[Sales Amount]),Sheet1[IsBeverage] IN {0,1}),IF(SELECTEDVALUE(Sheet1[IsBeverage])=0,CALCULATE(SUM(Sheet1[Sales Amount]))))
 
It would be a great help, If anyone can help on this issue.
 
Best Regards,
POWERBI

 

1 ACCEPTED SOLUTION

@Powers OK, use a disconnected table then. PBIX is attached and use a measure like this:

Measure = 
    VAR __Slicer = SELECTEDVALUE( 'Slicer'[IsBeverage] )
    VAR __IsBeverage = MAX( 'Table'[IsBeverage] )
    VAR __Sum = SUM( 'Table'[Sales Amount] )
    VAR __Result = 
        SWITCH( __Slicer, 
            1, __Sum,
            0, IF( __IsBeverage = 0, __Sum )
        )
RETURN
    __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

6 REPLIES 6
Greg_Deckler
Community Champion
Community Champion

@Powers You need to use ALL in order to override the filtering of the slicer so something like:

Isproduct = IF(SELECTEDVALUE(Sheet1[IsBeverage])=1,CALCULATE(SUM(Sheet1[Sales Amount]),FILTER( ALL( Sheet1), [IsBeverage] IN {0,1}) ,IF(SELECTEDVALUE(Sheet1[IsBeverage])=0,CALCULATE(SUM(Sheet1[Sales Amount]))))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler,

Thanks for the response. I have used your measure but still not getting 0 and 1 beverage products in the x-axis, instead it's only showing beverage 1 prouducts in the x-axis.

Powers_0-1724778801304.png

 

Best Regards,
POWERBI

@Powers OK, use a disconnected table then. PBIX is attached and use a measure like this:

Measure = 
    VAR __Slicer = SELECTEDVALUE( 'Slicer'[IsBeverage] )
    VAR __IsBeverage = MAX( 'Table'[IsBeverage] )
    VAR __Sum = SUM( 'Table'[Sales Amount] )
    VAR __Result = 
        SWITCH( __Slicer, 
            1, __Sum,
            0, IF( __IsBeverage = 0, __Sum )
        )
RETURN
    __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler , Thanks for the solution. It's working as expected and I have changed few logics in the measure as per my scenario but I solved this problem based your inputs. Thanks a lot.

 

 

Syk
Super User
Super User

Under your x-axis:

Syk_0-1724777438815.png

 

@Syk , Thanks for the response. But that's not working.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors