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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
M_SBS_6
Helper V
Helper V

Variance Year on Year

Hi, 

I have created a measure that I hoped would calculate the variance between current year and previous year but my calculation below is taking the variance current year vs the first year.

 

Example 

Year.   Value diff

2018.   0.39 0.00

2019.   0.22 -0.17

2020.   0.29 -0.10

 

Each value is based on the change from current year vs the first year (2018). What I need is this 

 

Year value diff

2018 0.39 0.00

2019 0.22- 0.17

2020 0.29 0.07

 

This is my current code. Any idea what I need to amend to make this work, please?

 

Diff=

Var __baseline_value=

Calculate([value], [year] in {"2018"}),

 

Var __measure_value = [value]

Return

If(not isblank(__measure_value), __measure_value - __baseline_value)

1 REPLY 1
amitchandak
Super User
Super User

@M_SBS_6 , Create a separate table with distinct years and join it with the year of your table (Say Date)

 

The create measures like example

//Only year vs Year, not a level below

This Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))
diff = [This Year]-[Last Year ]
diff % = divide([This Year]-[Last Year ],[Last Year ])

 

 

Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510
Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.