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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
GJeanes1
Frequent Visitor

YTD percentage with multiple years of data

So I have multiple years of data, and I cannot seem to get the correct YTD percentage total.

here is my measurement:

YTD Percentage Change =IF(ISFILTERED('Sheet1'[Date and Time]),ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column."),VAR __PREV_YEAR =CALCULATE(COUNTA('Sheet1'[Incident]),DATEADD('Sheet1'[Date and Time].[Date], -1, YEAR))RETURNDIVIDE(COUNTA('Sheet1'[Incident]) - __PREV_YEAR, __PREV_YEAR))

However, When I use my slicer to separate the "incident" value the YTD displays as

2023, 30, -48.61%

2022, 47, 24.14%...

But as you see using a YTD calculator

(30-47) / |47| * 100 = 36.17%

 

I am also using a filter for dates and manually updating or checking which dates to display.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @GJeanes1 ,

Please try:

YTD Percentage Change =
IF (
    ISFILTERED ( 'Sheet1'[Date and Time] ),
    ERROR ( "Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column." ),
    VAR __PREV_YEAR =
        CALCULATE (
            COUNTA ( 'Sheet1'[Incident] ),
            DATEADD ( 'Sheet1'[Date and Time].[Date], -1, YEAR )
        )
    VAR __SELECTED_DATE =
        DATESYTD ( MAX ( 'Sheet1'[Date and Time].[Date] ), "Calendar Year" )
    RETURN
        DIVIDE (
            CALCULATE ( COUNTA ( 'Sheet1'[Incident] ), __SELECTED_DATE ) - __PREV_YEAR,
            __PREV_YEAR
        )
)

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @GJeanes1 ,

Please try:

YTD Percentage Change =
IF (
    ISFILTERED ( 'Sheet1'[Date and Time] ),
    ERROR ( "Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column." ),
    VAR __PREV_YEAR =
        CALCULATE (
            COUNTA ( 'Sheet1'[Incident] ),
            DATEADD ( 'Sheet1'[Date and Time].[Date], -1, YEAR )
        )
    VAR __SELECTED_DATE =
        DATESYTD ( MAX ( 'Sheet1'[Date and Time].[Date] ), "Calendar Year" )
    RETURN
        DIVIDE (
            CALCULATE ( COUNTA ( 'Sheet1'[Incident] ), __SELECTED_DATE ) - __PREV_YEAR,
            __PREV_YEAR
        )
)

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Greg_Deckler
Community Champion
Community Champion

@GJeanes1 See if this video helps, it presents a bunch of different options for calculations like this:



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.