Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
kmax
Helper I
Helper I

Dax Measure to show CurrentYear vs PreviousYear

Hi,
I have a slicer with years (2020,2021,2022,2023)
I have a measure that shows average resolution time as below.

Avg Resolution Time (Year) = AVERAGE(Issues[Resolution Time (Days)])
I am creating a new year that shows the same data for the previous year with reference to current selected year.
But it is not working. In the visual it shows one single line. The first measure showing data correctly for alll the months of the selected year. But previous working measure is not working.
I have tried the following.
Avg Resolution Time (Previous Year by Month) =
VAR SelectedYear = MAX(Issues[Created].[Year])
VAR PreviousYear = SelectedYear - 1
RETURN
AVERAGEX(
FILTER(ALL(Issues), YEAR(Issues[Created]) = PreviousYear),
Issues[Resolution Time (Days)]
)


Avg Resolution Time (Previous Year) =
VAR SelectedYear = MAX(Issues[Created].[Year])
RETURN
CALCULATE(
AVERAGE(Issues[Resolution Time (Days)]),
FILTER(ALL(Issues), YEAR(Issues[Created]) = SelectedYear - 1)
)


5 REPLIES 5
DataNinja777
Super User
Super User

Hi @kmax,

What about simply like below?  

Sakiko_0-1694431264662.png

 

It shows an error "Parameter is not the correct type"

Sorry about it.  I fixed the syntax error.  Please let me know if it works now.  

Sakiko_1-1694431304973.png

 

Sorry for late reply. I am still getting an error when using the measure and Date column in to bar chart.Screenshot 2023-09-14 150845.jpg

Hi @kmax 

How was your Calendar table created?  Did you use the dax function "calendar" to create it?  The error message says that your date table contains duplicates, which should not be the case if you could establish a relationship with your fact table. 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 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.