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

retrieving average value for base year, by segments

Hi there,

Can anyone help with a query related to my previous one...trying to retrieve a calculated average value for a base year,  next to the selected later dates, and to be compatible with filters and selections.  eg. For compare Aug-24 Average value to Average Value for Aug-19, or for Jan-Aug 2024 Average compared to Average for Jan-Aug 2019, and to pull the same for Category (in this case the poast code)

 

See sample .pbix and data:

https://www.dropbox.com/scl/fi/kvtskvaur4ln37t8n7hob/power-BI-sample.pbix?rlkey=zu1hr8in8kqj7p96l8h3...

 

Using the following DAX brings back the correct 2019 Avg value for a month (but not a period eg Jan-Aug 2019), and also brings out a constant value by post code ? (see below picture)

Calc 2019 Avg = AVERAGEX( FILTER(ALL(Sheet1),Sheet1[year]=2019&&Sheet1[month]=MAX(Sheet1[month])),[Value])
 
dp_75_1-1729286846663.png

 

 Many thanks for your help !
DP_75

 

 

 

2 ACCEPTED SOLUTIONS
lbendlin
Super User
Super User

If you want to do date math you will want to add a calendar table to your data model.

 

Calc 2019 Avg = var yd = 2019-max('Calendar'[Year]) return CALCULATE(AVERAGE(Sheet1[value]),DATEADD('Calendar'[Date],yd,YEAR))

 

see attached.

View solution in original post

which values do you think are incorrect?  Remember that 2024 isn't complete yet.

View solution in original post

5 REPLIES 5
lbendlin
Super User
Super User

If you want to do date math you will want to add a calendar table to your data model.

 

Calc 2019 Avg = var yd = 2019-max('Calendar'[Year]) return CALCULATE(AVERAGE(Sheet1[value]),DATEADD('Calendar'[Date],yd,YEAR))

 

see attached.

Thanks Ibedlin ! That works for calculating the Avg in year by Category (in this case post code).  But what about calculating the % change from 2019 Avg by Category ?  In the attached this didn't pull back correct values ? using :

Calc % vs 2019 Avg = divide( average(Sheet1[value]),[Calc 2019 Avg])-1
 
Many thanks
dp_75
 

which values do you think are incorrect?  Remember that 2024 isn't complete yet.

Thanks Ibendlin - solution works for comparing years to 2019 base year, but as you say will not work for part year 2024.  Will need another solution to detected year to date 2024 data and compare to same year to date position for 2019, or full 2019 base year. 

My solution works for YTD - that should be acceptable.  No point in comparing partial 2024 to full 2019.

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.