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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
NewbieJono
Post Partisan
Post Partisan

Difference from previous Row

hello, I am looking to calculate the difference between the preview row in a matrix table.

 

I can do this in Excel, but not sure where to start with DAX.

 

Capture.PNG

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thank you @VahidDM  for your prompt reply.

Hi @NewbieJono  ,

Depending on the information you have provided, you can add a new measure:

NEW Difference =
VAR _Totalswtiches =
    SELECTEDVALUE ( 'Table'[Total_switches] )
VAR _MOVEAVERAGE =
    MAXX (
        FILTER ( ALL ( 'Table' ), [Total_switches] < _Totalswtiches ),
        [NEW Average]
    )
RETURN
    IF ( _Totalswtiches = 0, 0, SUM ( 'Table'[NEW Average] ) - _MOVEAVERAGE )

 Final output:

vyifanwmsft_0-1714374020198.png

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Ada Wang

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

3 REPLIES 3
Anonymous
Not applicable

Thank you @VahidDM  for your prompt reply.

Hi @NewbieJono  ,

Depending on the information you have provided, you can add a new measure:

NEW Difference =
VAR _Totalswtiches =
    SELECTEDVALUE ( 'Table'[Total_switches] )
VAR _MOVEAVERAGE =
    MAXX (
        FILTER ( ALL ( 'Table' ), [Total_switches] < _Totalswtiches ),
        [NEW Average]
    )
RETURN
    IF ( _Totalswtiches = 0, 0, SUM ( 'Table'[NEW Average] ) - _MOVEAVERAGE )

 Final output:

vyifanwmsft_0-1714374020198.png

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Ada Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

VahidDM
Super User
Super User

Hi @NewbieJono 

 

Create a measure using this DAX Expression:

Difference = 
VAR _L =
    CALCULATE (
        SUM ( 'Table'[Calendar Days] ),
        'Table'[Col Numbe]
            = ( MAX ( 'Table'[Col Numbe] ) - 1 )
    )
RETURN
    SUM ( 'Table'[Calendar Days] ) - _L

Output:

VahidDM_0-1714134390387.png

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!! 

LinkedIn | Twitter | Blog | YouTube 

Thank you, is there any method to stop day zero and the last zero showing incorrect. day zero difference should be 0. last day not calculating correct

 

Capture.PNG

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.