Forum Discussion

jjr333's avatar
jjr333
Advocate I
7 years ago
Solved

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)
  • jjr333's avatar
    jjr333
    7 years ago

    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())

     

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi jjr333,

     

    Try using SelectedValue function.

     

    This might help you.

     

    Regards,

    PavanVanguri.

    • jjr333's avatar
      jjr333
      Advocate I

      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())