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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors