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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.