Forum Discussion

awfrke's avatar
awfrke
Frequent Visitor
9 years ago
Solved

YOY % DAX Measure

Hi to all! I have a single table of values with brands, spends, months in the date format. One brand can have multiple spends during one months. I have a few functions already intact: Total ...
  • Anonymous's avatar
    Anonymous
    9 years ago

    Hi awfrke,

     

    According to your description, you want to get the result of current year spend / previous year spend, right?

     

    If it is a case, you can refer to below sample:

     

    Source table:

     

    Measures:

     

    Current Year Spends(All) = SUMX(FILTER(ALL(Sheet1),YEAR([Date])=YEAR(MAX([Date]))),[Spends])

    Previous Year Spends(all) = SUMX(FILTER(ALL(Sheet1),YEAR([Date])=YEAR(MAX([Date]))-1),[Spends])

     

    Previous Year Spends(Brand) =
    var temp= LASTNONBLANK(Sheet1[Brand],[Brand])
    return
    SUMX(FILTER(ALL(Sheet1),Sheet1[Brand]=temp&&YEAR([Date])=YEAR(MAX([Date]))-1),[Spends])

     

    Current Year Spends(Brand) =
    var temp= LASTNONBLANK(Sheet1[Brand],[Brand])
    return
    SUMX(FILTER(ALL(Sheet1),Sheet1[Brand]=temp&&YEAR([Date])=YEAR(MAX([Date]))),[Spends])

     

    YOY %(Brand) = DIVIDE( [Current Year Spends(Brand)],[Previous Year Spends(Brand)],0)

     

    YOY %(All) = DIVIDE( [Current Year Spends(all)],[Previous Year Spends(all)],0)

     

    Create visual to show the result:

     

    Regards,

    Xiaoxin Sheng