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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
kmax
Frequent Visitor

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors