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 August 31st. Request your voucher.
Hello there
TLDR: Based on a chosen month selected with a slicer (custom "Timeline 2.4" slicer) to compare numbers with exact same month last year. So lets say the user selects April 2023, I also want to show data for April 2022, especially the difference in %.
I've been searching and searching and tried different solutions without luck.
So I have some electricity sensor data for lets say 3 years based upon this calculated measure:
pervious sales =
VAR selectedmonth = CALCULATE(SUM(Measurements[numericValue),
[Month] = SELECTEDVALUE([Month]) && [Year] = Year(SELECTEDVALUE([Year]))
)
VAR selectedyear = CALCULATE(SUM(Measurements[numericValue),
[Month] = EOMONTH(SELECTEDVALUE([Month]), -12) && [Year] = Year(SELECTEDVALUE([Year]) - 1)
)
RETURN
DIVIDE(selectedmonth - selectedyear, selectedyear)
Hi,
Your sameperiod lastyear approach was close Here is a working pattern:
CALCULATE ( selectedmeasure(), SAMEPERIODLASTYEAR ( 'Calendar'[Date] ) )
Replace selectedmeasure with [Calculated_consumption] and use calendar table from your model. Your fact table should have 1:M relationship with the calendar.
For % change:
VAR LastYear = CALCULATE ( selectedmeasure(), SAMEPERIODLASTYEAR ( 'Calendar'[Date] ) ) RETURN DIVIDE(selectedmeasure()-LastYear,LastYear)
I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!
My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/
Proud to be a Super User!
User | Count |
---|---|
11 | |
9 | |
6 | |
6 | |
5 |
User | Count |
---|---|
23 | |
14 | |
14 | |
9 | |
7 |