Skip to main content
Microsoft Idea

Power BI

New

CONVERT_TO_MEASURE - Ability to convert a text value to a measure

Vote (21) Share
Jefferson Bauer's profile image

Jefferson Bauer on 28 Feb 2024 17:22:41

This concept would allow users to store meta data in a table and use it to dynamically convert the text value to a [measure] for calculating. Maybe a function called CONVERT_TO_MEASURE that takes a text value and returns an actual [measure] that can be used in dax calculations.

For example, suppose you have a table you keep in your model specific to organizing a report layout on a Matrix. On the table you store a field called UseMeasure. In that field you can specify a measure for row to use.


Dynamic Measure =

  VAR VarCalcType = SELECTEDVALUE('Report Layout'[CalcType])

  VAR varMeasure = CONVERT_TO_MEASURE(SELECTEDVALUE('Report Layout'[UseMeasure])) // <-- This would change the text value to a [measure]

  VAR varFormat = SELECTEDVALUE('Report Layout'[Format])

  VAR varSign = SELECTEDVALUE('Report Layout'[Sign])

 

 RETURN

 

  SWITCH(TRUE, VarCalcType = "USE_MEASURE", FORMAT(varMeasure * varSign, varFormat), BLANK())