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
svishwanathan
Helper III
Helper III

Difference for running total

Hello

 

I have a dataset that needs to be normalized. THere is a column for sales which is a running total. I want to derieve individual sales amount on each row so I can do calculations like ytd, qtd etc

 

Job        YYYYMM      Sales (Running Total)                    Sales (desired column)

A              201803           450                                                 200

B               201802            300                                                 200

A              201801            250                                                   50

A               201709            200                                                   200

B              201801              100                                                  100    

 

 

Regards

Swati

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

@svishwanathan

 

Give this a shot please

 

Sales Column =
VAR PreviousYYMM =
    CALCULATE (
        MAX ( TableName[YYYYMM] ),
        FILTER (
            ALLEXCEPT ( TableName, TableName[Job] ),
            TableName[YYYYMM] < EARLIER ( TableName[YYYYMM] )
        )
    )
VAR PreviousCumulative =
    CALCULATE (
        SUM ( TableName[Sales] ),
        FILTER (
            ALLEXCEPT ( TableName, TableName[Job] ),
            TableName[YYYYMM] = PreviousYYMM
        )
    )
RETURN
    TableName[Sales] - PreviousCumulative

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

@svishwanathan

 

Give this a shot please

 

Sales Column =
VAR PreviousYYMM =
    CALCULATE (
        MAX ( TableName[YYYYMM] ),
        FILTER (
            ALLEXCEPT ( TableName, TableName[Job] ),
            TableName[YYYYMM] < EARLIER ( TableName[YYYYMM] )
        )
    )
VAR PreviousCumulative =
    CALCULATE (
        SUM ( TableName[Sales] ),
        FILTER (
            ALLEXCEPT ( TableName, TableName[Job] ),
            TableName[YYYYMM] = PreviousYYMM
        )
    )
RETURN
    TableName[Sales] - PreviousCumulative

Thanks all work well 

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.

Top Solution Authors