The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
I have a report which contains a year slicer and a month slicer so you can select a specific scope for the related charts. Some charts will only look at the selected month in the selected year, but I need other charts to take the selected year and month and specifically look for the twelve months up to the selected year+month.
So for example if you select:
Then
I can't get Chart 2 to function propertly. The DAX query I'm working with seems to get close, but somehow doesn't do what I require:
Sales12M = CALCULATE ( SUM('data'[Sales]) / 1000; DATESBETWEEN ( 'Date'[YearMonthnumber]; SAMEPERIODLASTYEAR ( NEXTDAY ( LASTDATE ( 'YearMonths'[YearMonthnumber] ) ) ); LASTDATE ( 'YearMonths'[YearMonthnumber] ) ) )
I have tried fiddling around with a separate Date dates by day table and another YearMonths table that only shows 2016-01-01, 2016-02-01, etc.
What am I missing here?
Thanks in advance!
In your DAX formular, you iterated by MONTH with
DATESBETWEEN ( 'Date'[YearMonthnumber];....
And then used the NEXTDAY() function which pushes by a day. Try using the DAY iteration like this
Sales12M = CALCULATE ( SUM('data'[Sales]) / 1000; DATESBETWEEN ( 'Date'[Date]; SAMEPERIODLASTYEAR ( NEXTDAY ( LASTDATE ( 'YearMonths'[Date] ) ) ); LASTDATE ( 'YearMonths'[Date] ) ) )
I was wondering if you got this to work. I am having the same issue. I am about to just give up 😞
Using 2 slicer: Year and Month:
Use this Dax Code
12M = CALCULATE ( Sum(Sales[Value]), DATESBETWEEN ( 'Date'[Date], DATEADD ( FIRSTDATE ( 'Date'[Date] ), -1; YEAR ), LASTDATE ( 'Date'[Date] ) ) )
User | Count |
---|---|
69 | |
69 | |
66 | |
54 | |
28 |
User | Count |
---|---|
112 | |
82 | |
66 | |
48 | |
43 |