March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
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
Expected OutPut:
Power BI Reference Link:
https://1drv.ms/u/s!Au-aOkl1BoHuhxIPCmu25tKY_HLm?e=dFRnwZ
Thanks In Advance
Solved! Go to Solution.
Hi @Anonymous
Here is one way
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]))
Hi @Anonymous
Here is one way
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]))
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
21 | |
14 | |
11 | |
8 | |
5 |
User | Count |
---|---|
26 | |
21 | |
20 | |
14 | |
10 |