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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

August Carousel

Fabric Community Update - August 2024

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