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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Cummulative sum based on slicer selection

Hi Team,

 

Currently We've developed a visual showing that last 6 months of salesamount based on slicer(Month-Year) selection.

Problem Statement : Need to calculate dynamic cummulative sum of the last 6 months based on the slicer selection

 

Attached is the PBI Ref link : https://1drv.ms/u/s!Au-aOkl1BoHuhxIPCmu25tKY_HLm?e=dFRnwZ


For Ex:1 if we select dec-2017 then will showcase last 6 months(Dec-2017,nov-2017,oct-2017,sep-2017,aug-2017,july-2017)

   Ex2:if we select Aug-2018 then will showcase last 6 months(Aug-2018,July-2018,June-2018,May-2018,April-2019,Mar-2018)

 

Current OutPut

Current Image.png

Expected OutPut:

Cummulative Sum.png

 

Power BI Reference Link:

https://1drv.ms/u/s!Au-aOkl1BoHuhxIPCmu25tKY_HLm?e=dFRnwZ

 

Thanks In Advance

 

1 ACCEPTED SOLUTION
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

Here is one way

Vera_33_0-1637629939386.png

Sales (last n months) 1 = 
VAR MaxFactDate =
   CALCULATE ( MAX ( Sales[Date] ), ALL ( 'Date' ) ) -- ignore the selected date filter, and find the max of date in Sales table 
VAR FDate =
    ENDOFMONTH ( 'Date'[Date] ) -- get the last day of the month selected in the date filter
VAR Edate =
    EDATE ( FDate, -6 ) -- get the last day of -N months
RETURN
    IF(MaxFactDate<=FDate,
  SUMX(FILTER(ALL('Sales'),'Sales'[Date]<=MaxFactDate&&'Sales'[Date]>=Edate),Sales[Sales]))

 

View solution in original post

1 REPLY 1
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

Here is one way

Vera_33_0-1637629939386.png

Sales (last n months) 1 = 
VAR MaxFactDate =
   CALCULATE ( MAX ( Sales[Date] ), ALL ( 'Date' ) ) -- ignore the selected date filter, and find the max of date in Sales table 
VAR FDate =
    ENDOFMONTH ( 'Date'[Date] ) -- get the last day of the month selected in the date filter
VAR Edate =
    EDATE ( FDate, -6 ) -- get the last day of -N months
RETURN
    IF(MaxFactDate<=FDate,
  SUMX(FILTER(ALL('Sales'),'Sales'[Date]<=MaxFactDate&&'Sales'[Date]>=Edate),Sales[Sales]))

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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