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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
drew_darke
Frequent Visitor

Year over Year calculation generating -100% when month exists in last year but not this year

drew_darke_0-1642194519123.png

Hi all,
I am doing some year over year calculations and came across an issue I can't seem to solve. I am using the built in YoY quick measure. What's happening here is its trying to do the calculation for december 2021 because december 2020 exists, however there is no data for december 2021 (nor is there a date in the dataset for december 2021).

How do I get rid of this -100.00%?

Thanks!

1 ACCEPTED SOLUTION

Try checking for a blank sum:

VALUE YoY% =
IF (
    ISFILTERED ( 'TABLE'[REF_YEAR] ),
    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 (
            SUM ( 'TABLE'[VALUE] ),
            DATEADD ( 'TABLE'[REF_YEAR].[Date], -1, YEAR )
        )
    VAR __CURR_YEAR = SUM ( 'TABLE'[VALUE] )
    RETURN
        IF (
            ISBLANK ( __CURR_YEAR ) || ISBLANK ( __PREV_YEAR ),
            BLANK (),
            DIVIDE ( __CURR_YEAR - __PREV_YEAR, __PREV_YEAR )
        )
)

View solution in original post

2 REPLIES 2
drew_darke
Frequent Visitor

Here is the built in measure for reference

VALUE YoY% =
IF(
    ISFILTERED('TABLE'[REF_YEAR]),
    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(SUM('TABLE'[VALUE]), DATEADD('TABLE'[REF_YEAR].[Date], -1, YEAR))
    RETURN
        DIVIDE(SUM('TABLE'[VALUE]) - __PREV_YEAR, __PREV_YEAR)
)

Try checking for a blank sum:

VALUE YoY% =
IF (
    ISFILTERED ( 'TABLE'[REF_YEAR] ),
    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 (
            SUM ( 'TABLE'[VALUE] ),
            DATEADD ( 'TABLE'[REF_YEAR].[Date], -1, YEAR )
        )
    VAR __CURR_YEAR = SUM ( 'TABLE'[VALUE] )
    RETURN
        IF (
            ISBLANK ( __CURR_YEAR ) || ISBLANK ( __PREV_YEAR ),
            BLANK (),
            DIVIDE ( __CURR_YEAR - __PREV_YEAR, __PREV_YEAR )
        )
)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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