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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Modifying quick measure YoY%

I tried to modify the quick measure (Year over year change). Original DAX looks like:

 

Taxi Out Time, min YoY% =

VAR __PREV_YEAR = CALCULATE(SUM('QAR data'[Taxi Out Time, min]), DATEADD('DATES'[DATE_FULL], -1, YEAR))

RETURN
DIVIDE(SUM('QAR data'[Taxi Out Time, min]) - __PREV_YEAR, __PREV_YEAR)

 

I decided to make some modification:

 

Taxi Out Time (sum), min YoY% =

VAR a = SUM('QAR data'[Taxi Out Time, min])
VAR prev_a = CALCULATE(a, SAMEPERIODLASTYEAR(DATES[DATE_FULL]))

RETURN
DIVIDE(a - prev_a, prev_a)

 

But new formula didn`t work well:

Vadimych_0-1603177399333.png

(the first column is a month name in Russian)

 

Please help to understand, what am I doing wrong?

3 REPLIES 3
Anonymous
Not applicable

Variables in DAX are CONSTANTS. Once calculated, they are NEVER re-calculated.

amitchandak
Super User
Super User

@Anonymous , Make share months are coming from Dates Table

 

This year = SUM('QAR data'[Taxi Out Time, min])
last Year = CALCULATE([This year], SAMEPERIODLASTYEAR(DATES[DATE_FULL]))

Change % =
DIVIDE([This year] - [last Year], [last Year])

 

Please provide your feedback comments and advice for new videos
Tutorial Series Dax Vs SQL Direct Query PBI Tips
Appreciate your Kudos.

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
CNENFRNL
Community Champion
Community Champion

Hi, @Anonymous , the issue results from use of variable a in your measure; In fact, variables in DAX are NOT THAT VARIABLE as expected!

 

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.

 

You might want to refer to an article on this subject for more details.

 

A straightforward way is to create a measure a = SUM('QAR data'[Taxi Out Time, min]), and you can reference it in another measure.


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.