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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
dhkhanna
New Member

Switch definition of Calculated Column based on slicer

I am using an Entity Column as the primary axis for multiple reports in PowerBI. I have a requirement where I need to turn this into a calculated column, that takes its value from one of two columns. The decision on which column to use needs to be powered by a slicer. 

Currently, I have set up a "slicer" table that is simply as seen below:

Column
Yes
No

 

I then create a Calculated Column with the following definition - 

Column = IF(
HASONEVALUE('Table'[Value]),
SWITCH(
VALUES('Table'[Value]),
"Yes",A[Name1],
"No",A[Name2]))

My hope is that with the above definition, I should be able to select either "Yes" or "No" in the slicer to change the definition of the calculated column to either Name1 or Name2. The outcome would be that based on my selection of Yes or No, the entire report would switch to using Name1 or Name2 as the axis in its visualizations. 

Currently, this calculated column simply returns a blank value. 

How can I modify this DAX to achieve my intended results? If not possible, are there any other options to achieve the same?

Thanks
1 REPLY 1
amitchandak
Super User
Super User

@dhkhanna , You can not create a calculated column , based on Slicer values. You can create only measure.

 

In case of direct Query, Dynamic M parameter can help 

 

refer these

 

Axis Slicer
Three approch from Guyinacube https://www.youtube.com/watch?v=dYmzb5UMkXw
Dynamically change chart axis in Power BI
bookmark -https://blog.crossjoin.co.uk/2018/04/20/dynamically-changing-a-chart-axis-in-power-bi-using-bookmarks-and-buttons/
https://radacad.com/bookmarks-and-buttons-making-power-bi-charts-even-more-interactive
https://www.youtube.com/watch?v=6jeSIRpjv0M
https://datamonkeysite.com/2020/10/22/change-dimension-dynamically-using-parameter-in-powerbi/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.