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

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

Reply
dcheng029
Helper II
Helper II

How to have slicer change graph Y-axis when selection is made?

Hi all,

 

I am working with two datasets where [A] shows a list of all items with the relevant staff and business area and [B] shows a list of all staff and their relevant department and executive. [B] has a one-to-many relationship with [A] using the staff columns.

 

On my dashboard, I have an Executive filter from [B]. I want my column graph to show the Department from [B] as the Y-axis when no selection is made on the Executive filter and Business Area from [A] as the Y-axis when a selection is made on the Executive filter.

 

Due to the complexity and sensitivity of my dataset I have included the below summary instead; hoping anyone can help here.

 

dcheng029_0-1756180137713.png

 

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@dcheng029 

 

11.png12.png

 

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

6 REPLIES 6
danextian
Super User
Super User

Hi @dcheng029 

 

Create a disconnected table that combines both department and business are columns into one.

BusinessArea_Dept = 
VAR _BA =
    SELECTCOLUMNS ( DatasetA, "Category", DatasetA[Business Area] )
VAR _dept =
    SELECTCOLUMNS ( DatasetB, "Category", DatasetB[Department] )
RETURN
    DISTINCT ( UNION ( _BA, _dept ) )

Create this measure

Row Count = 
COUNTROWS ( DatasetA )
---can be any other aggregation

Switch Measure = 
VAR _BA =
    CALCULATE (
        [Row Count],
        TREATAS ( VALUES ( BusinessArea_Dept[Category] ), DatasetA[Business Area] )
    )
VAR _Dept =
    CALCULATE (
        [Row Count],
        TREATAS ( VALUES ( BusinessArea_Dept[Category] ), DatasetB[Department] )
    )
RETURN
    IF ( ISFILTERED ( DatasetB[Executive] ), _BA, _Dept )

 

danextian_0-1756190192491.gif

Please see the attached pbix

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
ryan_mayu
Super User
Super User

@dcheng029 

 

11.png12.png

 

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @ryan_mayu 

Many thanks! This worked a charm and was exactly what I was after. I have incorporated your logic to my actual dataset and it translated perfectly. Cheers!

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Shahid12523
Community Champion
Community Champion

You can do this with DAX + dynamic axis:

 

Create a measure to check if Executive is selected:

 

IsExecutiveSelected =
IF(ISFILTERED(TableB[Executive]), "Business Area", "Department")


Create a measure for axis value:

 

Dynamic Axis =
SWITCH(
[IsExecutiveSelected],
"Business Area", SELECTEDVALUE(TableA[Business Area]),
"Department", SELECTEDVALUE(TableB[Department])
)


Create a measure for count:

 

Dynamic Count =
SWITCH(
[IsExecutiveSelected],
"Business Area", COUNTROWS(TableA),
"Department", COUNTROWS(TableB)
)


Use Dynamic Axis on chart axis and Dynamic Count as value.

Chart will switch between Department and Business Area automatically based on Executive slicer.

Shahed Shaikh

This only switches the table which rows are to be counted but not what to show in the X/Y axis. 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

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.