- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Trying to create TYD Variance measure with variables and not getting a result
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Ive got it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Ive got it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

@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...
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!: Power BI Cookbook Third Edition (Color)
DAX is easy, CALCULATE makes DAX hard...

Helpful resources
Subject | Author | Posted | |
---|---|---|---|
07-10-2024 02:08 PM | |||
07-30-2024 05:25 AM | |||
03-06-2024 04:49 AM | |||
06-10-2024 04:23 AM | |||
07-30-2024 03:35 PM |
User | Count |
---|---|
121 | |
104 | |
85 | |
52 | |
46 |