Forum Discussion

egrospe17's avatar
egrospe17
Frequent Visitor
1 year ago
Solved

Measure for YoY YTD

Hello DAX Gods, I have this table in one of my PowerBI reports that shows YoY % Revenue growth. For the most part, this looks right with the execption of the current year because we are only in Sept...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi egrospe17 

    Based on your needs, I have created the following table.

     

    First you can use the following Measure to get the total revenue every year.

    Total Revenue = 
    VAR _year = [Year]
    RETURN
    SUMX(FILTER(ALL('Table'),'Table'[Year]=_year),'Table'[Revenue])

     

    Then you can use the following Measure to get the result you want:

    YoY % Revenue growth = 
    VAR _year = [Year]
    VAR _sameperiodtotal = CALCULATE ( [Total Revenue], DATESYTD ( SAMEPERIODLASTYEAR ( 'Table'[Date] ) ) )
    VAR _maxmonth = MAXX (
                FILTER ( ALL ( 'Table' ), 'Table'[Year] = _year ),
                MONTH ( 'Table'[Date] )
            )
    RETURN
        IF (
             _maxmonth< 12,
            DIVIDE (
                SUMX ( FILTER ( ALL ( 'Table' ), 'Table'[Year] = _year ), 'Table'[Revenue] ),
                SUMX (
                    FILTER (
                        ALL ( 'Table' ),
                        'Table'[Year] = _year - 1
                            && MONTH ( 'Table'[Date] )
                                <= _maxmonth
                    ),
                    'Table'[Revenue]
                )
            )-1,
            DIVIDE (
                [Total Revenue]-_sameperiodtotal,
                _sameperiodtotal
            )
        )



     

     

     

     

     

     

     

     

    Best Regards,

    Jayleny

     

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