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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
svishwanathan
Helper III
Helper III

Difference on running total

I have a dataset that is not normalized. One of the columns contains running total of sales. Based on this column, I want a Sales column that gives sales for each month. This column will help me to do calculations like ytd, qtd and mtd

 

Job             YYYYMM                Running Total    Sales (Desired Col)

A                   201803                      450                                 150         

B                    201803                     300                                  250                        

A                    201712                      300                                  50

A                    201710                      250                                   250

B                     201802                      50                                     50                           

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @svishwanathan,

 

Please try this formula:

Sales =
'Job Sales'[Running Total]
    - LOOKUPVALUE (
        'Job Sales'[Running Total],
        'Job Sales'[Job], 'Job Sales'[Job],
        'Job Sales'[YYYYMM], CALCULATE (
            MAX ( 'Job Sales'[YYYYMM] ),
            FILTER (
                ALLEXCEPT ( 'Job Sales', 'Job Sales'[Job] ),
                'Job Sales'[YYYYMM] < EARLIER ( 'Job Sales'[YYYYMM] )
            )
        )
    )

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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

1 REPLY 1
v-yulgu-msft
Employee
Employee

Hi @svishwanathan,

 

Please try this formula:

Sales =
'Job Sales'[Running Total]
    - LOOKUPVALUE (
        'Job Sales'[Running Total],
        'Job Sales'[Job], 'Job Sales'[Job],
        'Job Sales'[YYYYMM], CALCULATE (
            MAX ( 'Job Sales'[YYYYMM] ),
            FILTER (
                ALLEXCEPT ( 'Job Sales', 'Job Sales'[Job] ),
                'Job Sales'[YYYYMM] < EARLIER ( 'Job Sales'[YYYYMM] )
            )
        )
    )

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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