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

Preparing for a certification exam? Ask exam experts all your questions on May 15th. 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
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors