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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Singh_Yoshi
Helper I
Helper I

Help me with DAX

Hi,

 

I have following table called Table1 as below,

Model CodeMSRP
FJ11120000
FJ12136000
FJ13219800
FJ14260000
FJ15325670

 

I want to subtract FJ11(MSRP) from FJ12(MSRP), FJ12(MSRP) from FJ13(MSRP) and so on.

FJ11 Corresponsing cell should be Blank. Please see below for desired output and kindly help me DAX code. Thank you in advance.

Model CodeMSRPLC
FJ111200000
FJ1213600016000
FJ1321980083800
FJ1426000040200
FJ1532567065670
1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a calculated  column.

 

Jihwan_Kim_0-1735482343639.png

 

OFFSET function (DAX) - DAX | Microsoft Learn

 

LC Calculated Column =
VAR _currentrow = 'Table 1'[MSRP]
VAR _previousrow =
    MAXX (
        OFFSET (
            -1,
            'Table 1',
            ORDERBY ( 'Table 1'[Model Code], ASC ),
            ,
            ,
            MATCHBY ( 'Table 1'[Model Code] )
        ),
        'Table 1'[MSRP]
    )
RETURN
    IF ( NOT ISBLANK ( _previousrow ), 'Table 1'[MSRP] - _previousrow )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
ryan_mayu
Super User
Super User

@Singh_Yoshi 

you can also try this

 

Column =
VAR _last=maxx(FILTER('Table','Table'[Model Code]<EARLIER('Table'[Model Code])),'Table'[Model Code])
return if (_last="",BLANK(),'Table'[MSRP]-maxx(FILTER('Table','Table'[Model Code]=_last),'Table'[MSRP]))
 
11.PNG




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a calculated  column.

 

Jihwan_Kim_0-1735482343639.png

 

OFFSET function (DAX) - DAX | Microsoft Learn

 

LC Calculated Column =
VAR _currentrow = 'Table 1'[MSRP]
VAR _previousrow =
    MAXX (
        OFFSET (
            -1,
            'Table 1',
            ORDERBY ( 'Table 1'[Model Code], ASC ),
            ,
            ,
            MATCHBY ( 'Table 1'[Model Code] )
        ),
        'Table 1'[MSRP]
    )
RETURN
    IF ( NOT ISBLANK ( _previousrow ), 'Table 1'[MSRP] - _previousrow )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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