As in any other programming language, you can also use variables in DAX. (But unlike in other languages, you don´t need them too much. It just makes the syntax slightly clearer.)


Few more notes about variables in DAX:

  • Variable can refer to other variable
  • Variable cannot vary during calculation (so, honestly, it is not a variable...)
  • Variables are calculated on the beginning - before the RETURN command - and can be used repeatedly. So they are calculated just once - which makes it quicker to calculate.
  • Variables are evaluated in the initial context
  • Variable can contain single value or a table

The syntax is easy. We can define the variable, then write RETURN a normally continue with calculation.

Here we define a measure variable:

And here we define a table variable:

Leave a Reply

Your email address will not be published.


clear formPost comment