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
Anonymous
Not applicable

Subtracting Not Working as Expected

Hello -

 

I am working on subtracting Current Data with Past Data using a unique ID to find the last historic value for each unique item. I have successfully calculated the previous value by using the following DAX function:

 

Previous Data = 
'Table'[Current Data]
    - MAXX(
        FILTER('Table',
            'Table'[Index]
            = EARLIER('Table'[Index]) - 1
            && 'Table'[UID] = EARLIEST('Table'[UID])
        ),
        'Table'[Current Data]
    )

 

 

Now that I have this value, I want to subract the each individual row from 'Table' [Current Data] from 'Table' [Previous Data] to get a delta/change value for each row. I used the following as an example:

 

Delta = 'Table'[Current Data] - 'Table'[Previous Data]

 

 

However, when using the above "Delta" calculation all of the values result as "0", and I cannot understand why this is happening.

Below is an example of what I would expect to happen with the delta calculation:

UIDDateCurrent DataPrevious DataDelta
12/3/2157478532(2785)
22/3/21467221342538
11/5/21853285320
31/3/21941971282291
21/6/2121349024(6890)
21/2/21902490240
312/4/20712871280

 

Thank you in advance for any assistance!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous ,a new column, you can use index in place of date

 

Diff Previous Data =
var _max = maxx(filter( 'Table','Table'[UID] = EARLIEST('Table'[UID]) , 'Table'[Date] < EARLIER('Table'[Date])),[Date])
return
if(isblank(_max) , 0 , [Current Data] -maxx(filter( 'Table','Table'[UID] = EARLIEST('Table'[UID]) , 'Table'[Date] =_max),[Current Data] ) ) 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

This seems to have worked perfectly! Thank you!

amitchandak
Super User
Super User

@Anonymous ,a new column, you can use index in place of date

 

Diff Previous Data =
var _max = maxx(filter( 'Table','Table'[UID] = EARLIEST('Table'[UID]) , 'Table'[Date] < EARLIER('Table'[Date])),[Date])
return
if(isblank(_max) , 0 , [Current Data] -maxx(filter( 'Table','Table'[UID] = EARLIEST('Table'[UID]) , 'Table'[Date] =_max),[Current Data] ) ) 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

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!

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.

Top Solution Authors
Top Kudoed Authors