Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
rajulshah
Super User
Super User

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.

1 ACCEPTED SOLUTION
az38
Community Champion
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


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

3 REPLIES 3
az38
Community Champion
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


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Hello @az38,

 

Thanks for the answer. I actually tried to investigate using Performance Analyzer, but wasn't able to conclude properly.

 

Thanks again!

amitchandak
Super User
Super User

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.