Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
I have data as shown in a small snippet below. I would like to add a new column that shows the difference from one row to the next. Can anyone show me the DAX code to do this?
Solved! Go to Solution.
My mistake, I changed my mind about where to put the check for 0 index whilst I was writing it.
Diff to previous =
var currentIndex = 'Table'[index]
IF( currentIndex > 0,
var currentValue = 'Table'[Value]
var prevValue = LOOKUPVALUE( 'Table'[Value], 'Table'[index], currentIndex - 1)
return currentValue - prevValue
)
Diff to previous = IF( currentIndex > 0,
var currentIndex = 'Table'[index]
var currentValue = 'Table'[Value]
var prevValue = LOOKUPVALUE( 'Table'[Value], 'Table'[index], currentIndex - 1)
return currentValue - prevValue
)
Hi @johnt75 ,
Tried your code but currentIndex on line 1 is greyed out and gives the error "Failed to resolve name 'currentIndex'. Rest of the lines seem to work fine. Any idea how to fix this?
My mistake, I changed my mind about where to put the check for 0 index whilst I was writing it.
Diff to previous =
var currentIndex = 'Table'[index]
IF( currentIndex > 0,
var currentValue = 'Table'[Value]
var prevValue = LOOKUPVALUE( 'Table'[Value], 'Table'[index], currentIndex - 1)
return currentValue - prevValue
)
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.