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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Dvaudreuil
New Member

Year over Year metric calculation (I'm stumped!)

Hey everyone-

I am trying to figure out the easiest way to calculate Year over Year growth on a simple matrix visual.  The ask from the business users is to simply see the YoY% growth for each month/year based on the filters they apply in the slicers at the top of the report (see below).  For example, the YoY% increase in January 2019 (501) and 2020 (473) should be -5.59%.  I would like to display the # in a card visual if possible.  Any help would be appreciated!

 

Dvaudreuil_2-1628862578908.png

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi @Dvaudreuil ,

 

I made a simple sample from part of your data:

Create a measure as below:

YoY% increase =
VAR _maxyear =
    CALCULATE ( MAX ( 'Table'[Year] ), ALLSELECTED ( 'Table'[Year] ) )
VAR _minyear =
    CALCULATE ( MIN ( 'Table'[Year] ), ALLSELECTED ( 'Table'[Year] ) )
RETURN
    IF (
        NOT ( ISFILTERED ( 'Table'[Month] ) ),
        DIVIDE (
            CALCULATE (
                SUM ( 'Table'[Value] ),
                FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Year] = _minyear )
            )
                - CALCULATE (
                    SUM ( 'Table'[Value] ),
                    FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Year] = _maxyear )
                ),
            CALCULATE (
                SUM ( 'Table'[Value] ),
                FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Year] = _minyear )
            )
        ),
        DIVIDE (
            CALCULATE (
                SUM ( 'Table'[Value] ),
                FILTER (
                    ALLSELECTED ( 'Table' ),
                    'Table'[Year] = _minyear
                        && 'Table'[Month] = SELECTEDVALUE ( 'Table'[Month] )
                )
            )
                - CALCULATE (
                    SUM ( 'Table'[Value] ),
                    FILTER (
                        ALLSELECTED ( 'Table' ),
                        'Table'[Year] = _maxyear
                            && 'Table'[Month] = SELECTEDVALUE ( 'Table'[Month] )
                    )
                ),
            CALCULATE (
                SUM ( 'Table'[Value] ),
                FILTER (
                    ALLSELECTED ( 'Table' ),
                    'Table'[Year] = _minyear
                        && 'Table'[Month] = SELECTEDVALUE ( 'Table'[Month] )
                )
            )
        )
    )

And you will see:

vkellymsft_3-1629186303370.png

 

vkellymsft_2-1629186287599.png

 

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my reply as a solution!

 

View solution in original post

5 REPLIES 5
v-kelly-msft
Community Support
Community Support

Hi @Dvaudreuil ,

 

I made a simple sample from part of your data:

Create a measure as below:

YoY% increase =
VAR _maxyear =
    CALCULATE ( MAX ( 'Table'[Year] ), ALLSELECTED ( 'Table'[Year] ) )
VAR _minyear =
    CALCULATE ( MIN ( 'Table'[Year] ), ALLSELECTED ( 'Table'[Year] ) )
RETURN
    IF (
        NOT ( ISFILTERED ( 'Table'[Month] ) ),
        DIVIDE (
            CALCULATE (
                SUM ( 'Table'[Value] ),
                FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Year] = _minyear )
            )
                - CALCULATE (
                    SUM ( 'Table'[Value] ),
                    FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Year] = _maxyear )
                ),
            CALCULATE (
                SUM ( 'Table'[Value] ),
                FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Year] = _minyear )
            )
        ),
        DIVIDE (
            CALCULATE (
                SUM ( 'Table'[Value] ),
                FILTER (
                    ALLSELECTED ( 'Table' ),
                    'Table'[Year] = _minyear
                        && 'Table'[Month] = SELECTEDVALUE ( 'Table'[Month] )
                )
            )
                - CALCULATE (
                    SUM ( 'Table'[Value] ),
                    FILTER (
                        ALLSELECTED ( 'Table' ),
                        'Table'[Year] = _maxyear
                            && 'Table'[Month] = SELECTEDVALUE ( 'Table'[Month] )
                    )
                ),
            CALCULATE (
                SUM ( 'Table'[Value] ),
                FILTER (
                    ALLSELECTED ( 'Table' ),
                    'Table'[Year] = _minyear
                        && 'Table'[Month] = SELECTEDVALUE ( 'Table'[Month] )
                )
            )
        )
    )

And you will see:

vkellymsft_3-1629186303370.png

 

vkellymsft_2-1629186287599.png

 

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my reply as a solution!

 

Thank you for this Kelly!

Hi  @Dvaudreuil ,

 

Glad to help.😊

 

Best Regards,
Kelly

Did I answer your question? Mark my reply as a solution!

Dvaudreuil
New Member

Thank you amitchandak!  I will give this a try. 

amitchandak
Super User
Super User

@Dvaudreuil , You have to create a measure. and add it

 

with help from date table 

 

This Year = CALCULATE(sum("order"[Qty]),filter(ALL("Date"),"Date"[Year]=max("Date"[Year])))
Last Year = CALCULATE(sum("order"[Qty]),filter(ALL("Date"),"Date"[Year]=max("Date"[Year])-1))

diff = [This Year]-[Last Year ]
diff % = divide([This Year]-[Last Year ],[Last Year ])

 

other option

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD("Date"[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd("Date"[Date],-1,Year),"12/31"))

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.