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
Anonymous
Not applicable

Running Total after certain Month

Hi Experts,

Having a little difficulty in getting Power BI to calculate a running total after a certain month.

 

So I am trying to calculate the running total after a certain month. But its a little complicated. The months after March are forecasted and need to be running totals from the previous month. So April should be 3500 for Trousers from the example below. However in the raw data it is actually 500. Is there a way to manipulate the data like this without affecting the prior months?

 

I have 2 tables in the model

Sales table

Calender table

(The product field is in the Sales table)

-Sales Field

-Date Field

-Product Field

 

I am using a matrix to visualise this...

 

Productjanfebmaraprmayjunjul
Trousers (Current)200040003000500600800100

Trousers (Desired)

2000400030003500410049005000

 

thank you in advance!

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @Anonymous ,

 

Based on what you have described, you want to calculate the cumulative total after a month. Is a certain month a fixed value? Or a dynamic value? If it's a dynamic value, what's the logic behind it.

If the month is a fixed value,please try to create measure like this.

RunningTotal =
IF (
    MAX ( 'Table'[date] ) >= DATE ( 2020, 3, 1 ),
    CALCULATE (
        SUM ( 'Table'[sales] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[product] ),
            'Table'[date] >= DATE ( 2020, 3, 1 )
                && SUMX (
                    FILTER ( 'Table', EARLIER ( 'Table'[date] ) <= 'Table'[date] ),
                    'Table'[sales]
                )
        )
    ),
    MAX ( 'Table'[sales] )
)

test_Running Total after certain Month.PNG

Sample .pbix

 

Best Regards,
Liang
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

4 REPLIES 4
V-lianl-msft
Community Support
Community Support

Hi @Anonymous ,

 

Based on what you have described, you want to calculate the cumulative total after a month. Is a certain month a fixed value? Or a dynamic value? If it's a dynamic value, what's the logic behind it.

If the month is a fixed value,please try to create measure like this.

RunningTotal =
IF (
    MAX ( 'Table'[date] ) >= DATE ( 2020, 3, 1 ),
    CALCULATE (
        SUM ( 'Table'[sales] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[product] ),
            'Table'[date] >= DATE ( 2020, 3, 1 )
                && SUMX (
                    FILTER ( 'Table', EARLIER ( 'Table'[date] ) <= 'Table'[date] ),
                    'Table'[sales]
                )
        )
    ),
    MAX ( 'Table'[sales] )
)

test_Running Total after certain Month.PNG

Sample .pbix

 

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

amitchandak
Super User
Super User

@Anonymous ,

Try like

Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(date,date[date] <=maxx(date,date[date])), Date[Date]>=date(2020,01,31))

or

Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(date,date[date] <=max(Sales[Sales Date])), Date[Date]>=date(2020,01,31))

Anonymous
Not applicable

Hi @amitchandak 

 

thank you for your suggestion. But it is still not working. Tried both your formulas..

Does this calc work on Product line level?

 

Is it possible to only use the date in the Sales table?

 

ProductJanFebMarApr
Trousers (raw data)20001000500600
Trousers (desired)2000100015002100
Tshirts (Desired)3000400046005200

@Anonymous , Can you share raw data and sample output in table format? Or a sample pbix after removing sensitive data.

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.