Forum Discussion
When is expression in VAR calculated?
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.
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
3 Replies
- amitchandak
Super User
rajulshah , to calculate it beforehand you might use sumx or calculate.
refer if these can help
- az38
Community Champion
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