DAX variables

Variables can be defined within DAX measures and primarily serve to improve the readability of DAX expressions. Rather than creating and referencing separate DAX measures, variables provide an inline option, thereby limiting the volume of distinct measures in a dataset. As a basic example of variable syntax, the "Last Refreshed" text message described in the Parameter Tables section of Chapter 8Connecting to Sources and Transforming Data with M, uses a DAX variable in its expression, as follows:

Last Refresh Msg =   VAR CurrentDateValue = MAX('CurrentDate'[CurrentDate])  RETURN  "Last Refreshed: " & CurrentDateValue  

The VAR function is used to name a variable and the RETURN keyword allows for the variable's result to be referenced ...

Get Microsoft Power BI Complete Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.