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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
SSIAB
New Member

How to calculate difference in previous row?

I have a date column that is sorted by week. I have another coulmn labeled PC valued with data values. How can I calculate to see the difference between each week in the PC column? Here is a screen shot below. 

SSIAB_0-1718656932906.png

 

1 ACCEPTED SOLUTION
Irwan
Super User
Super User

Hello @SSIAB 

 

please check if this will acommodate your need.

Irwan_2-1718668993558.pngIrwan_3-1718669029269.png

 

1. create calculated column for calculating week as you want to see weekly value difference

Week = WEEKNUM('Table'[Date],21) //put 21 for ISOWEEKNUM or depend on what you need

2. find previous week value then substract current week with previous week

Diff =
var _PreviousValue = MAXX(FILTER('Table','Table'[Week]<EARLIER('Table'[Week])),'Table'[Value]) //find previous week value
Return
'Table'[Value]-_PreviousValue
 
The first value return as 149 as there is no previous value, otherwise if you want to make it zero at the very first line then use this dax instead:
Diff =
var _PreviousValue = MAXX(FILTER('Table','Table'[Week]<EARLIER('Table'[Week])),'Table'[Value]) //find previous week value
Return
IF(
    'Table'[Week]=MIN('Table'[Week]),
    0,
    'Table'[Value]-_PreviousValue
)
Irwan_1-1718668954043.pngIrwan_5-1718669363926.png

 

 
Hope this will help you.
Thank you.

View solution in original post

1 REPLY 1
Irwan
Super User
Super User

Hello @SSIAB 

 

please check if this will acommodate your need.

Irwan_2-1718668993558.pngIrwan_3-1718669029269.png

 

1. create calculated column for calculating week as you want to see weekly value difference

Week = WEEKNUM('Table'[Date],21) //put 21 for ISOWEEKNUM or depend on what you need

2. find previous week value then substract current week with previous week

Diff =
var _PreviousValue = MAXX(FILTER('Table','Table'[Week]<EARLIER('Table'[Week])),'Table'[Value]) //find previous week value
Return
'Table'[Value]-_PreviousValue
 
The first value return as 149 as there is no previous value, otherwise if you want to make it zero at the very first line then use this dax instead:
Diff =
var _PreviousValue = MAXX(FILTER('Table','Table'[Week]<EARLIER('Table'[Week])),'Table'[Value]) //find previous week value
Return
IF(
    'Table'[Week]=MIN('Table'[Week]),
    0,
    'Table'[Value]-_PreviousValue
)
Irwan_1-1718668954043.pngIrwan_5-1718669363926.png

 

 
Hope this will help you.
Thank you.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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