Forum Discussion

rbriga's avatar
rbriga
Impactful Individual
4 years ago
Solved

Calculation Groups- More Than One Measure For Each Calculation Item

Hi all,

I have created a claculation group in which each calculation item is a different existing measure.

This allows the user to change the measure a visual shows, and it works great.

The ca

 

However, now I want to add a second measure- a target.

I was hoping to to use SELECTEDVALUE('Metric Selection'[Metric]) to pick a target,

but any measure referencing 'Metric Selection'[Metric] just returns the underlying measure in the selected calculation item, for example- Reviews.

 

Is there any DAX expression that will return the name of the selected calculation item?

Thank you.The user picks a measure (calculation item) to choose what the visual shows.My calculation group.

  • I think this can be avoided by using if within the calculation group.
    So if you include this logic in the calculation items it should work:
    IF(selectedmeasurename()="Name of calc grp",selectedmeasure(), Your original calculation item logic)

    Alternative option would be to make another calculation group which would have the logic I described above and assign its precedence to be before the original calculation group.

     

     

4 Replies

  • ValtteriN's avatar
    ValtteriN
    Community Champion

    Hi (by the way I love your report theme),

    I am pretty sure calculation groups don't have anything like SELECTEDMEASURENAME, but as a workaround you could just use MAX('MI Metric Selection'[Name]) In you example it should return "Reviews".

    I hope this helps to solce your issue and if it does consider accepting this as a solution!

    • rbriga's avatar
      rbriga
      Impactful Individual

      Thank you- it's rather close, but not there yet.

      MAX('MI Metric Selection'[Metric]) return a metric name when nothing is selected from the calculation group (e.g. disabling the filtering from "edit interactions"), but when a calculation item is chosen, this measure return the chosen metric's resault (a number) rather than the name.

       

      I can't overcome this sticky, tenacious behavior that any measure that's affected by a calculation group returns it's value, but not name.

      Solutions that work on DAX Studio don't work in the roeport itsels.

      Even the Measure 

      Twelve = 12
      Returns the chosen calculated item when plotted together.
  • ValtteriN's avatar
    ValtteriN
    Community Champion

    I think this can be avoided by using if within the calculation group.
    So if you include this logic in the calculation items it should work:
    IF(selectedmeasurename()="Name of calc grp",selectedmeasure(), Your original calculation item logic)

    Alternative option would be to make another calculation group which would have the logic I described above and assign its precedence to be before the original calculation group.

     

     

    • rbriga's avatar
      rbriga
      Impactful Individual

      It worked! You're awesome!

      I have created another Calculation Group with 2 measures: Value and Target. I gave it precedence over the original group.

      I have changed the calculated items this way- for example, Reviews:

      IF(SELECTEDMEASURENAME()="Target",
      [An expression that uses SELECTEDVALUE('MI Metric Selection'[Metric]) to get the Revies Target},
      [Reviews]
      )

       Finally, in the visual I shared, I now plot the Value from this new calculation group (here it would return [Reviews]) and the Target. Perfect!