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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

How to plot cumulative sales for each month separately

Hi,

I have a requirement wherein I need to plot the cumulative sales against date for each month in line chart. Here month will be selected in slicer (e.g November 2024).

 

Sample Data is given below.

DateSales
1-Oct-24     1
2-Oct-24     2
3-Oct-24     0
4-Oct-24     0
5-Oct-24     4
6-Oct-24     0
7-Oct-24     5
1-Nov-24    10
2-Nov-24     0
3-Nov-24    12
4-Nov-24     0
5-Nov-24     5
6-Nov-24     0
7-Nov-24     7

 

If we select the period in slicer as November 20204, the graph shouls how below data.

1st Nov - 10

2nd Nov - 10

3rd Nov - 22

4th Nov - 22

5th Nov - 27

6th Nov - 27

7th Nov - 34

and till November 30 it should show as 34th. Suppose if a sale of 5 happens on November 29th, then it should show the cumulative sale as 39 on November 29th and show the same till end of the month.

 

I have written the below DAX to find the cumulative sales.

TotalSales =
VAR _maxdate = MAX('Date'[Date])
VAR _totalsales = CALCULATE(SUM(SalesData[Sales]),FILTER(ALL('Date'),'Date'[Date]<= _maxdate))
RETURN
_totalsales
But when I select the slicer as November 2024,
1) the starting value on Nov 1st should be 10, but it is showing as 22 ( adding the sale of 10 on Nov 1st with the total sales in October 2024 ie 12).
2) It is showing the data only till today ie November 26th 2024. But it must show the graph till November 30th 2024. (If we put the filter as December 2024 on December 1st, it should show the graph till december 31st)
 
Please help me to accomplish this task successfully.

 

inikhilpv_1-1732626692547.png

 

Thanks in advance,

Nikhil

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You can use

Total Sales = CALCULATE( SUM( SalesData[Sales] ), DATESMTD( 'Date'[Date] ) )

View solution in original post

2 REPLIES 2
johnt75
Super User
Super User

You can use

Total Sales = CALCULATE( SUM( SalesData[Sales] ), DATESMTD( 'Date'[Date] ) )
Anonymous
Not applicable

Thank you so much. It worked.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors