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

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.

Reply
adityakumar619
Helper II
Helper II

How to find the running diffrence of two columns using dax

Hi Team,

 

Can you please help to find the Running diff total of below two columns i.e DEPR_Value and Total cost

 

Note:here Total cost is the fixed value

 

first row o/p :16680-170.45=16509.55

second row o/p:16509.55-170.45=16339.1

third row o/p:16339.1-0.63=16338.47

and so on.

 

Also i tried with different Dax but no luck.

 

SERIALFISCAL_YEARPERIODDEPR_ValueTotal costRunning diff total
MXQ914020194170.451668016509.55
MXQ914020195170.451668016339.1
MXQ9140201950.631668016338.47
MXQ9140201950.631668016337.84
MXQ914020196213.061668016124.78
MXQ9140201960.781668016124
MXQ914020197170.451668015953.55
MXQ9140201970.631668015952.92
MXQ914020198170.451668015782.47
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @adityakumar619 ,

Please try to create a new column with below dax formula:

Column =
VAR cur_serial = [SERIAL]
VAR cur_date = [Date]
VAR tmp =
    FILTER ( ALL ( 'Table' ), [SERIAL] = cur_serial && [Date] <= cur_date )
VAR min_date =
    MINX ( tmp, [Date] )
VAR start_val =
    CALCULATE (
        MAX ( [Total cost] ),
        'Table'[SERIAL] = cur_serial,
        'Table'[Date] = min_date,
        ALL ( 'Table' )
    )
VAR sum_dv =
    SUMX ( tmp, [DEPR_Value] )
RETURN
    start_val - sum_dv

vbinbinyumsft_0-1696563813208.png

Please refer the attached .pbix file

 

Best regards,
Community Support Team_Binbin Yu
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

11 REPLIES 11
Anonymous
Not applicable

Hi @adityakumar619 ,

Please try below steps:

1. please add a new index column in Power Query Pane

 

2. create a measure with below dax formula

Running diff total =
VAR total_cost =
    SELECTEDVALUE ( 'Table'[Total cost] )
VAR cur_index =
    SELECTEDVALUE ( 'Table'[Index] )
VAR tmp =
    FILTER ( ALL ( 'Table' ), [Index] <= cur_index )
VAR _a =
    SUMX ( tmp, [DEPR_Value] )
RETURN
    total_cost - _a

3. add a table visual with fields and measure

vbinbinyumsft_0-1695868982054.png

Please refer the attached .pbix file

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@Anonymous I hope you got my query,Please let me know if you need any further details.

Anonymous
Not applicable

Hi @adityakumar619 ,

Sorry, I could not access the link, please share the desensitized .pbix file with other way.

It would be good to provide a screenshot of the results you are expecting and desensitized example data.

 

Best regards,
Community Support Team_Binbin Yu

@Anonymous for sure will accept it,but just to clarify what if i have multiple serial numbers.can you please check once on this.

https://drive.google.com/file/d/18oglhVf_NCrPrjanuQ-0Uf6SklhVVg-Z/view?usp=sharing 

 

@Anonymous  I have attached the pbix file in my one drive ,Please find the above link(I have given the permission to access the file aswell) i don't have any option to upload the files directly.

Sorry for that.In this pbix file i have all the details interms of what is expected.

 

Excel Data:

https://docs.google.com/spreadsheets/d/1c3INBU7GMcW-dwtE8jVpupyx90dx-WVv/edit?usp=sharing&ouid=107317045258698142200&rtpof=true&sd=true 

 

 

 

 

 

 

Anonymous
Not applicable

Hi @adityakumar619 ,

Please try to create a new column with below dax formula:

Column =
VAR cur_serial = [SERIAL]
VAR cur_date = [Date]
VAR tmp =
    FILTER ( ALL ( 'Table' ), [SERIAL] = cur_serial && [Date] <= cur_date )
VAR min_date =
    MINX ( tmp, [Date] )
VAR start_val =
    CALCULATE (
        MAX ( [Total cost] ),
        'Table'[SERIAL] = cur_serial,
        'Table'[Date] = min_date,
        ALL ( 'Table' )
    )
VAR sum_dv =
    SUMX ( tmp, [DEPR_Value] )
RETURN
    start_val - sum_dv

vbinbinyumsft_0-1696563813208.png

Please refer the attached .pbix file

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@Anonymous I hope you access the above content,if not will share via your mail id.

@Anonymous I have added the pbix file in google drive and i also added multiple serial numbers previously if you see only one serial number 

adityakumar619
Helper II
Helper II

SERIAL

FISCAL_YEARPERIODDEPR_ValueTotal costRunning diff total
MXQ914020194170.451668016509.55
MXQ914020195170.451668016339.1
MXQ9140201950.631668016338.47
MXQ9140201950.631668016337.84
MXQ914020196213.061668016124.78
MXQ9140201960.781668016124
MXQ914020197170.451668015953.55
MXQ9140201970.631668015952.92
MXQ914020198170.451668015782.47

 

Sample data

Can someone please help on the Dax to accomplish the desired calculation

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.