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
tester
Frequent Visitor

Delta Calculation per Time Period for Group Values

I've seen a hundred posts on this but no real solution. 

 

My data:

 

GroupDateValue
a1/13/2015897
a1/9/2015200
a1/1/2015647
b1/13/20152
b1/9/2015978
b1/1/2015655
c1/13/201561
c1/9/201536
c1/1/2015959


What I need: a delta calculation that subtracts the difference of each value from last week, for each group. Ergo:

 

GroupDateValueDelta
a1/13/2015897697
a1/9/2015200-447
a1/1/20156470
b1/13/20152-976
b1/9/2015978323
b1/1/20156550
c1/13/20156125
c1/9/201536-923
c1/1/20159590

 

Note where the delta is 0.

 

This is easily achieved in R:

 

dataset %>%
group_by(Group) %>%
mutate(Delta = Value - lag(Value, order_by=Date))

Unfortunately there's no real enterprise support for R in PBI Service. So how do we do this with M/DAX?

1 ACCEPTED SOLUTION
1 REPLY 1
tester
Frequent Visitor

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.