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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
jburton
Frequent Visitor

using a measure name as a variable in another measure

I have a Power BI matrix that looks something like this:

 

jburton_0-1719257153103.png

 

Typically how this may look in power bi is the "type" column is a row value from the data and the "quantity" is a count distinct of the ID in the table. 

Our current table is actually made with measures as the rows rather than a grouping by columns. "Type 1" is one measure, "Type 2" is another, and so on. 

 

 

When I hover over a measure in the matrix I need to be able to display data about that measure in a tooltip. To do this I would want to pass the measure name as a variable similar to the behavior of SELECTEDVALUE([type]) in the first option. Example:

SWITCH( [SELECTED MEASURE NAME]

, "Type 1", Calcuate()

, "Type 2", Calculate()

...

)


Are there any Dax commands that could accomplish this?

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@jburton Hmm, I don't think so as SELECTEDMEASURE only works with Calculation Groups. Perhaps if you can share some sample data and your measure formulas there might be an alternative. For example, switch the matrix back to columns instead of values on rows. Create a disconnected table with your types in a single column, we'll call this table Table and the column Column. Then you could create a single measure like this:

Measure = 
  VAR __Type = MAX('Table'[Column])
  VAR __Result = 
    SWITCH( __Type,
      "Type 1", [Type 1],
      "Type 2", [Type 2],
      "Type 3", [Type 3],
      "Type 4", [Type 4],
      "Type 5", [Type 5],
      "Type 6", [Type 6],
      "Type 7", [Type 7]
    )
RETURN
  __Result

Now replace all of your other measures in your matrix with this measure. Now you have a column that you can easily use in a SWITCH statement to identify what to do.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

1 REPLY 1
Greg_Deckler
Community Champion
Community Champion

@jburton Hmm, I don't think so as SELECTEDMEASURE only works with Calculation Groups. Perhaps if you can share some sample data and your measure formulas there might be an alternative. For example, switch the matrix back to columns instead of values on rows. Create a disconnected table with your types in a single column, we'll call this table Table and the column Column. Then you could create a single measure like this:

Measure = 
  VAR __Type = MAX('Table'[Column])
  VAR __Result = 
    SWITCH( __Type,
      "Type 1", [Type 1],
      "Type 2", [Type 2],
      "Type 3", [Type 3],
      "Type 4", [Type 4],
      "Type 5", [Type 5],
      "Type 6", [Type 6],
      "Type 7", [Type 7]
    )
RETURN
  __Result

Now replace all of your other measures in your matrix with this measure. Now you have a column that you can easily use in a SWITCH statement to identify what to do.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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