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
Murten
Frequent Visitor

Compare data/calculations for a chosen month with same month last year

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: 

Calculated_consumption= (CALCULATE(SUM(Measurements[numericValue]), Measurements[field] = "consumption", Measurements[deviceid] = "X") / 1000). 
There are timestamp, date, month-year etc columns. I've tried with all columns refering to some kind of "date" or "timestamp"...

When the user selects for example April 2023 the dashboards shows electricity  consumption for that given month. But I also want a box showing the change from April 2022. 

So far I've only managed to create tables and graphs that can compare to previous month.. 

The solutions that didn't work for me:
X = CALCULATE(([Calculated_consumption]),
DATEADD(Measurements[MonthYear],-1, YEAR))

- Y 
 = CALCULATE([Calculated_consumption], SAMEPERIODLASTYEAR(Measurements[MonthYear]))

- Z = 
 CALCULATE([Calculated_consumption], PARALLELPERIOD(Measurements[MonthYear],-12,MONTH))


Thanks in advance

2 REPLIES 2
devanshi
Helper V
Helper V

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)

ValtteriN
Super User
Super User

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/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.