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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
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.