cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
neilcotton
Regular Visitor

Cumulative Totals on a Filtered Period / Item

Good afternoon all.

I've been looking for a solution to this and tried many of the solutions already mentioned, but these all only seem to work with SET, framed data.

 

What I am trying to achieve (in my head) sounds like it should be a pretty standard requirement for most organisations.

Example:

  • A sales table contains Item Number, Qty, SalesDate, SalesYearMonth
  • A line chart shows the SalesYearMonth on the Axis and Cumulative Sales Qty as the Value.
  • Two filters on the page, Item Number and SalesYearMonth.
  • When a filter is applied, the Cumulative value should reflect whatever filter has been applied.
ItemNumberQuantitySales Invoice DateSales Year Month
ProdA52 Jan 20222022-01
ProdA205 Jan 20222022-01
ProdB106 Jan 20222022-01
ProdB1210 Feb 20222022-02
Prod A3015 Feb 2022

2022-02

Prod C10020 Feb 2022

2022-02

Prod C2525 Feb 2022

2022-02

Prod C304 Mar 2022

2022-03

Prod A407 April

2022-04

 

So if no filter is applied, it the line chart should look like:

Sales Year MonthCumulative Sales Qty
2022-0135
2022-0235+167 = 202
2022-0335+167+30 = 232
2022-0435+167+30+40 = 272

 

However, if they selected Date Range 2022-03 to 2022-04 the chart would show

Sales Year MonthCumulative Sales Qty
2022-0330 
2022-0430+40 = 70             

 

And if they just selected Product A and no date filter, the chart would show

Sales Year MonthCumulative Sales Qty
2022-0125
2022-0225+30 = 55
2022-0325+30+0 = 55
2022-0425+30+0+40 = 95

 

Non of the solutions I've found regarding cumulative calculations, allows for this level of flexability.

 

Please help.

Regards

 Neil

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I suggest having a calendar table like below.

Please check the below picture and the attached pbix file.

 

Picture2.png

 

Cumulative sales qty: =
CALCULATE (
    SUM ( Data[Quantity] ),
    FILTER (
        ALLSELECTED ( 'Calendar' ),
        'Calendar'[Date] <= MAX ( 'Calendar'[Date] )
    )
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

2 REPLIES 2
neilcotton
Regular Visitor

Thanks @Jihwan_Kim 

That's perfect

Jihwan_Kim
Super User
Super User

Hi,

I suggest having a calendar table like below.

Please check the below picture and the attached pbix file.

 

Picture2.png

 

Cumulative sales qty: =
CALCULATE (
    SUM ( Data[Quantity] ),
    FILTER (
        ALLSELECTED ( 'Calendar' ),
        'Calendar'[Date] <= MAX ( 'Calendar'[Date] )
    )
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors