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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
kmax
Helper I
Helper I

Current Year vs Previous Year

Hi,
I am working on a report that finds average resolution time. 
I can find the average resolution time of current year using the following measure.

Average Days to Resolve CY =

VAR TotalResolutionTime2023 =
    CALCULATE(
        [Total Resolution Time],
        FILTER(
            'Issues',
            'Issues'[YearResolved] = 2023
        )
    )
VAR TotalTickets2023 =
    CALCULATE(
        [TotalTickets],
        FILTER(
            'Issues',
            'Issues'[YearResolved] = 2023
        )
    )
RETURN
    DIVIDE(
        TotalResolutionTime2023,
        TotalTickets2023,
        0
    )

I have created similar measures for years 2022 and 2021. 
I have a year slicer [2020, 2021, 2022, 2023]
All the columns are in a single table. I have created new columns for month, and year from the date column in the same table.
What I want is if 2023 is selected from the slicer, the data in the line chart or bar chart should show values of the Current year (selected) and the previous year. In the case of the bar chart, two bars (one for 2023 and the second for 2022). Similarly if 2022 is selected from the slicer, it should show data for 2022 and 2021.
I tried using year(lastyear) -1 but it is not working. 
I have attached the screenshot of how it is showing for now.
Any idea, how can I achieve it?
Screenshot 2023-09-14 033057.jpg
Thanks in advance
1 REPLY 1
lbendlin
Super User
Super User

Add a calendar table to your data model.  Use standard time intelligence functions like SAMEPERIODLASTYEAR or DATEADD.

 

Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot). Leave out anything not related to the issue.
https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.