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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
hmahmudi2
Frequent Visitor

How to swich column based on the calue of SELECTEDVALUE?

Hi all;

 

I am stacked in getting the value of SELECTEDVALUE in calculated column. The DAX formula I am using is returning blank while the same formula works and returns value when used with a measure.

The DAX formula I am using looks like following:

 

Legend = 
    SWITCH(
        SELECTEDVALUE(Metrics[Metrics Fields]),
       "'MyMeasures'[% 0-5 months]",[% 0-5 months category],
       "'MyMeasures'[% 6-23 months]",[% 6-23 months category]
    ) 

 

 

thanks

5 REPLIES 5
johnt75
Super User
Super User

It won't work in a calculated column. Columns are only calculated during data refresh and so do not take into account any slicers or filters. Why do you need it in a column rather than in a measure? Is it something you could achieve with a fields parameter ?

Thanks for the respose.

I use parameter to display the data on a map when selected in a slicer. Beside this i need to add a legend on the map that divides the displayed data into 4 categories. Any way, I need a solution to switch columns based on the selected value of the slicer.

I think a fields parameter might work, add both measures to the field parameter and then use the slicer that automatically gets generated. add the fields parameter to all visuals and it should work I think.

Thanks

That works and I have tested it. My case is a bit different. I need one parameter value to do to things. First it populate the select column/measure on the map and secondly it process and categorize the select column into a categorical feature and then add on the map as a legend value. The first works but the second does not work.

 

The only thing I can think of is to add another column to the fields parameter table, link it to whichever table is driving the categories, so that a selection of the fields parameter filters the categories.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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