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