Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi guys,
Hope you're doing well.
I wonder what is the impact of creating VAR in a DAX formula. I have formulas like below :
var CB1111_vs_ns=DIVIDE([Direct COGS Ref],[Net Sales Ref])
var CB1120_vs_ns=DIVIDE([Indirect COGS], [Net Sales Ref])
I use them in a SWITCH in the return part.
These VAR are very simples so I think that I could write directly them in the switch so my formula is shorter and maybe it could optimize the performance. The goal is optimize as much as possible the performance.
Could you advice me ?
Thank you
Hello @bboy0009 ,
so Var stands for variable, you would use it with you want to create a measure that needs multiple calculations so instead of creating multilple measures and then using them in one, you could do all this in one measure by using variables.
a simple example:
these are three measures to get the profit:
Total revenue = sum (revenue)
Total Cost = sum ( cost)
Profit = Total revenue - Total Cost
Now will do the same in one measure and still get same result:
Profit =
var revenue = sum ( revenue)
var cost = sum(cost)
return
revenue - cost
you could also check this article https://www.sqlbi.com/articles/variables-in-dax/
If I answered your question, please mark my post as solution, Appreciate your Kudos 👍
Proud to be a Super User! | |
please just don't answer just for answer like so many
come on please read the post first before answering
I didn't ask you what is a VAR. I asked for performance's questions
Thank you anyway !
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!