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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. 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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.