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!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Solved! Go to Solution.
Ive got it
Hi @DebbieE ,
In DAX, variables are calculated within the scope in which they are written, and then the result of them is stored and used in the rest of the expression. See more: Caution When Using Variables in DAX and Power BI.
You may change the formula like DAX below.
YTD Sales Var =
VAR TYTD = TOTALYTD(SUM(Table1[Sales]), DimDate[FullDateAlternateKey])
VAR LYTD = CALCULATE(SUM(Table1[Sales]) ,SAMEPERIODLASTYEAR(DimDate[FullDateAlternateKey]))
RETURN TYTD-LYTD
For reference:
https://community.powerbi.com/t5/Desktop/var-different-result/td-p/283143
https://community.powerbi.com/t5/Desktop/VAR-different-result-than-without-it/td-p/518723
Best Regards,
Amy
Community Support Team _ Amy
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
VAR LYTD = CALCULATE (SUM (Table1 [Sales]), SAMEPERIODLASTYEAR (DimDate [FullDateAlternateKey]))
But this isnt calculating the Year to date measure that Im basing last year on so this wouldnt work?
As in my TYTD variable
TOTALYTD (SELECTEDMEASURE (), DimDate [FullDateAlternateKey])
I should say, Im trying to do some work on calulated groups with Tabular Editor and Im trying to find ways of recreating my measures so they could be used for calculated groups and its proving really difficult
Ive got it
@DebbieE - You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000
Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.
https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...