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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Jayshamone
Helper I
Helper I

DAX Measure Reference Performance

Hello,

I understand that using variables much more efficient than definining calculations multiple times within one measure. 
Calculating a ratio however, creates another performance question, I cannot find an answer to. The formula would be something like this (with a and b being measures that are already defined elsewhere):

   c:= IF(a && b; DIVIDE(ab) - 1; BLANK())


Should I define a and b as variables within c?

Or are a and considered as constant values within c after the first calculation which would make the measure reference more efficent?

 

Thank you

Justus

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Jayshamone , something like this should be better

 

Measure =
Var _a =a
Var _b = b
return
if(isblank(_a) ||isblank(_b) ,DIVIDE(a-b; b) , blank)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@Jayshamone , something like this should be better

 

Measure =
Var _a =a
Var _b = b
return
if(isblank(_a) ||isblank(_b) ,DIVIDE(a-b; b) , blank)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Greg_Deckler
Community Champion
Community Champion

@Jayshamone VAR's are constants, they cannot be recalculated. So yes, you should define a and b as VAR's and use those var's in your final calculation.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thank you, @Greg_Deckler for your quick response.

So a and b would indeed be recalcualted in c?
This would mean that if I make a change to a, I would need to make the same change to var a in c making it harder to maintain.
 

@Jayshamone I'm not sure what you are saying by recalculate. VAR's do not recalculate:

 

Measure =
  VAR __a = [a]
  VAR __b = [b]
RETURN
  IF(ISBLANK(__a) || ISBLANK(__b),BLANK(),DIVIDE(__a, __b,BLANK()) - 1)

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors