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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
kadekwijaya
Regular Visitor

Calculate % difference between each year of a row

Hi,

 

I am trying to find the % difference e.g. change in consumption between 2021 and 2020 then 2022 and 2021:

 

kadekwijaya_0-1677775701285.png

This is not a calculated column so can be edited in Power Query editor

Thanks!

1 ACCEPTED SOLUTION

Hi, @kadekwijaya 

 

You can try the following methods.
Measure:

Change% = 
Var _Previousyear=CALCULATE(SUM('Table'[Consumption]),FILTER(ALL('Table'),[Year]=SELECTEDVALUE('Table'[Year])-1))
Var _Currentyear=SUM('Table'[Consumption])
Return
IF(_Previousyear=BLANK(),BLANK(),DIVIDE(_Currentyear-_Previousyear,_Currentyear))

vzhangti_0-1678086211674.png

Column = 
Var _Previousyear=CALCULATE(SUM('Table'[Consumption]),FILTER('Table',[Year]=EARLIER('Table'[Year])-1))
Var _Currentyear=[Consumption]
Return
IF(_Previousyear=BLANK(),BLANK(),DIVIDE(_Currentyear-_Previousyear,_Currentyear))

vzhangti_1-1678086320613.png

Is this the result you expect?

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
FreemanZ
Super User
Super User

hi @kadekwijaya 

you want a solution in PQ?

 

With DAX, try plot a visual with Year column and a measure like:

Measure =
VAR _year = MAX (TableName[year])
VAR _ConsLY = 
SUMX(
     FILTER(
        ALL(TableName),
        TableName[Year] = _year -1
    ),
   TableName[consumption]
)
VAR _Cons = 
SUM(TableName[consumption]) 
RETURN
DIVIDE(_Cons - _ConsLY, _ConsLY)

Thanks for the suggestion!

 

I would ideally like a table showing the change in consumption as a % between each year?

E.g. 2020 will be blank but 2021 and 2022 will have % values?

Hi, @kadekwijaya 

 

You can try the following methods.
Measure:

Change% = 
Var _Previousyear=CALCULATE(SUM('Table'[Consumption]),FILTER(ALL('Table'),[Year]=SELECTEDVALUE('Table'[Year])-1))
Var _Currentyear=SUM('Table'[Consumption])
Return
IF(_Previousyear=BLANK(),BLANK(),DIVIDE(_Currentyear-_Previousyear,_Currentyear))

vzhangti_0-1678086211674.png

Column = 
Var _Previousyear=CALCULATE(SUM('Table'[Consumption]),FILTER('Table',[Year]=EARLIER('Table'[Year])-1))
Var _Currentyear=[Consumption]
Return
IF(_Previousyear=BLANK(),BLANK(),DIVIDE(_Currentyear-_Previousyear,_Currentyear))

vzhangti_1-1678086320613.png

Is this the result you expect?

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.