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
jjr333
Advocate I
Advocate I

Dynamic Column calculation based on Slicer Selection

Is it possible to select a column dynamically, based on selection of a slicer item?

The slicer contains the column names.

I am trying to avoid having to write a number of similar Measures using SWITCH.

Code below does not work.

Cheers, J.

Dynamic Count = VAR varSelectedItem = [ItemSelection] // value from slicer with column names
                VAR varCountColumn = "factSanSeb[" & varSelectedItem & "]"
                RETURN COUNTA(varCountColumn)
1 ACCEPTED SOLUTION

Hello Pavan,

The solution below works. But I am trying to avoid having to write many Measures.

 

AVE Readings = IF(HASONEVALUE(MeasuredValues[Measure]);
                        SWITCH(SELECTEDVALUE(MeasuredValues[Measure]);
                        "NO";[NO Ave];
                        "SO2";[SO2 Ave];
                        "NO2";[NO2 Ave];
                        "O3";[O3 Ave];
                        "PM10";[PM10 Ave];
                        "PM2,5";[PM2,5 Ave];
                        "Precip.";[Precip. Ave];
                        "Other"
                        ); BLANK())

9-4-2019 12-50-29.png

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @jjr333,

 

Try using SelectedValue function.

 

This might help you.

 

Regards,

PavanVanguri.

Hello Pavan,

The solution below works. But I am trying to avoid having to write many Measures.

 

AVE Readings = IF(HASONEVALUE(MeasuredValues[Measure]);
                        SWITCH(SELECTEDVALUE(MeasuredValues[Measure]);
                        "NO";[NO Ave];
                        "SO2";[SO2 Ave];
                        "NO2";[NO2 Ave];
                        "O3";[O3 Ave];
                        "PM10";[PM10 Ave];
                        "PM2,5";[PM2,5 Ave];
                        "Precip.";[Precip. Ave];
                        "Other"
                        ); BLANK())

9-4-2019 12-50-29.png

 

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.