Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi,
I'm new to DAX and getting my feet wet. I'm trying to define a variable in the formula bar. However, everytime I go, NEW MEASURE, I go to the formula bar and enter in a formula with a VAR, it's stays greyed out. I can't hit the check mark or the "X".
Thanks for any hints.
@datafiend Please hold "Shift" key and press "Enter" to go to the next line.
If this post helps, then please consider accepting it as the solution to help other members find it more quickly. Thank You!!
The first line is the variable, but I can't hit enter to go to Line 2. I can change the MEASURE NAME, I can enter stuff in the first line, but I can't hit ENTER to go to Line 2. I must be missing something fundamental.
Hello @datafiend , we dont have any command or function as VAR while writing DAX but still it picks the value like dont wait for any drop down continue writing your measure.
For example:
Month over Month sales =
Var Current_Month = Calculate(Sum(Sales))
Var Previous_Month = Calcuate(Sum(sales),PreviousMonth(dates))
Var Result = If(Previous_Month = blank(),blank(), Current_Month-Previous_Month)
Return
Result
If this post helps, then please consider accepting it as the solution to help other members find it more quickly. Thank You!!
Hi @datafiend ,
I did not really get your point. However, I guess the code you have to write is the following:
TotalSales_w_increase =
VAR increase = 0.05
RETURN [TotalSales] * (1 + increase)
where TotalSales is a measure already created.
The first line is your variable. It only exists in this measure. You can't use it in another one.
The second line is your return statement. This is the value your measure returns. The idea is to use your variable "increase" in your return statement. Variables are useful when you use multiple times the same part of code in the measure definition.
If I answered your question, please mark my post as a solution.
Best,
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!