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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
Super User
Super User

@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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

1 REPLY 1
Greg_Deckler
Super User
Super User

@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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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