Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hello everyone,
I want to know that does the variables are already calculated before RETURN statement?
For example:
Measure =
VAR A = SUM(Table[ColumnA])
VAR B = SUM(Table[ColumnB])
RETURN
IF(TODAY()=DATE(2020,07,11),A,B)
So, in the measure above,
will both the variables A & B be calculated and then the RETURN statement is executed?
OR
It would first check the condition and then calculate A or B according to the condition?
I have checked out multiple videos & blogs, but it doesn't answer my question.
Any help is appreciated.
Thanks.
Solved! Go to Solution.
Hi @rajulshah
Yes, VARiables are calculated before the RETURN
So, if you do want to reduce amount of calculation you can calculate it inside RETURN statement
Also, I highly recommend you to try both options and compare its in the built-in Performance Analyzer https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
Hi @rajulshah
Yes, VARiables are calculated before the RETURN
So, if you do want to reduce amount of calculation you can calculate it inside RETURN statement
Also, I highly recommend you to try both options and compare its in the built-in Performance Analyzer https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
Hello @az38,
Thanks for the answer. I actually tried to investigate using Performance Analyzer, but wasn't able to conclude properly.
Thanks again!
@rajulshah , to calculate it beforehand you might use sumx or calculate.
refer if these can help
https://powerbi.tips/2017/05/using-variables-within-dax/