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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

Regards
Zubair

Please try my custom visuals

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

Regards
Zubair

Please try my custom visuals

Thanks all work well 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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