Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi!
I'm just curious how does DAX execute VAR/ RETURN lines? Will it
For example I have a measure with the following lines below. Since I did not use VAR2 in my RETURN statement, will it still evaluate VAR2?
Measure = VAR1 = SUM(Table[Column1]) VAR2 = SUM(Table[Column2]) VAR3 = SUM(Table[Column3]) RETURN DIVIDE(VAR1, VAR3)
Thanks!
Solved! Go to Solution.
Hi @Anonymous
The compiler will check for potential errors but at execution time the variable will only be evaluated if it's invoked in the RETURN part. For instance:
Measure = VAR VAR1 = SUM(Table1[Column1]) VAR VAR2 = 3/VALUES(Table1[Column1]) VAR VAR3 = SUM(Table1[Column1]) RETURN VAR1
will NOT generate an error even though at VAR2 we are dividing by a column but this will:
Measure = VAR VAR1 = SUM(Table1[Column1]) VAR VAR2 = 3/VALUES(Table1[Column1]) VAR VAR3 = SUM(Table1[Column1]) RETURN VAR2
Hi @Anonymous
The compiler will check for potential errors but at execution time the variable will only be evaluated if it's invoked in the RETURN part. For instance:
Measure = VAR VAR1 = SUM(Table1[Column1]) VAR VAR2 = 3/VALUES(Table1[Column1]) VAR VAR3 = SUM(Table1[Column1]) RETURN VAR1
will NOT generate an error even though at VAR2 we are dividing by a column but this will:
Measure = VAR VAR1 = SUM(Table1[Column1]) VAR VAR2 = 3/VALUES(Table1[Column1]) VAR VAR3 = SUM(Table1[Column1]) RETURN VAR2
User | Count |
---|---|
84 | |
79 | |
71 | |
48 | |
43 |
User | Count |
---|---|
111 | |
54 | |
50 | |
40 | |
40 |