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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
MichaelB_MO
New Member

YoY Calculations DAX formula Help

Good morning,

I am trying to develop a YoY view.  I am currently utilizing the following formula:

Previous Year Calls = calculate (distinctcount('Database 1'[Incident Number]), dateadd('Calendar Table'[Date].[date],-1,year))

Here is how the visual appears:

MichaelB_MO_0-1730477802747.png

When I use this code:

Previous Year Calls 2var cycalls = distinctcount(Database 1[Incident Number])
var pycalls = calculate (distinctcount('Database 1'[Incident Number]), previousyear('Database 1'[Dispatched Date]))
var check = cycalls <> blank() && pycalls <> blank()
return if(check,divide(cycalls,pycalls)-1)
Returns the same results.
 
I am looking to be able to have 2023 values appear next to 2024, 2022 next to 2023, 2021 next to 2022 and 2020 next to 2021.  
 
Any assistance would be greatly appreciated.  
 
Michael
1 ACCEPTED SOLUTION
v-xingshen-msft
Community Support
Community Support

Hi @MichaelB_MO ,

You want to calculate the growth rate of each year compared to the previous year, right? Here's an example of how I've used the sample data to help you.

We first create a YEAR column so that we can do a better calculation, then we sum each year separately and do a year-over-year growth rate calculation.

Current Year Calls = 
 CALCULATE(DISTINCTCOUNT('Table'[Incident Number]),ALLEXCEPT('Table','Table'[Year]))
Previous Year Calls = 
CALCULATE(
    DISTINCTCOUNT('Table'[Incident Number]),
    FILTER(
        ALL('Table'),
        'Table'[Year] = MAX('Table'[Year]) - 1
    )
)
YoY Growth Rate = 
VAR CurrentCalls = [Current Year Calls]
VAR PreviousCalls =[Previous Year Calls]
RETURN
    IF(
        NOT(ISBLANK(CurrentCalls)) && NOT(ISBLANK(PreviousCalls)),
        DIVIDE(CurrentCalls - PreviousCalls, PreviousCalls, 0),
        BLANK()
    )

vxingshenmsft_0-1730688106396.png

If you have further questions, you can check my pbix file or feel free to reply to me, I will get back to you as soon as I hear from you, I would be honored if my solution solves your problem!

Hope it helps!

 

Best regards,
Community Support Team_ Tom Shen

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

2 REPLIES 2
v-xingshen-msft
Community Support
Community Support

Hi @MichaelB_MO ,

You want to calculate the growth rate of each year compared to the previous year, right? Here's an example of how I've used the sample data to help you.

We first create a YEAR column so that we can do a better calculation, then we sum each year separately and do a year-over-year growth rate calculation.

Current Year Calls = 
 CALCULATE(DISTINCTCOUNT('Table'[Incident Number]),ALLEXCEPT('Table','Table'[Year]))
Previous Year Calls = 
CALCULATE(
    DISTINCTCOUNT('Table'[Incident Number]),
    FILTER(
        ALL('Table'),
        'Table'[Year] = MAX('Table'[Year]) - 1
    )
)
YoY Growth Rate = 
VAR CurrentCalls = [Current Year Calls]
VAR PreviousCalls =[Previous Year Calls]
RETURN
    IF(
        NOT(ISBLANK(CurrentCalls)) && NOT(ISBLANK(PreviousCalls)),
        DIVIDE(CurrentCalls - PreviousCalls, PreviousCalls, 0),
        BLANK()
    )

vxingshenmsft_0-1730688106396.png

If you have further questions, you can check my pbix file or feel free to reply to me, I will get back to you as soon as I hear from you, I would be honored if my solution solves your problem!

Hope it helps!

 

Best regards,
Community Support Team_ Tom Shen

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

 

adudani
Super User
Super User

hi @MichaelB_MO ,

 

this can be achieved with calculation groups. 

Once you create the TY and LY calculation items, add the "Fiscal/ calendar year" in the columns of the matrix. 

 

this should provide the intended result. for reference: Dynamic YTD Metric in Power BI Using Field Parameters and Calculation Groups 


if this doesn't resolve the issue, kindly provide a sample input and output masking sensitive information in a usable format ( excel, csv, link to pbix etc.)

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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