Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Sameperiodlastyear per category

My first post ever 🙂 Hi, I have the following table called Transactions from an online shop: Order ID     Item ID   Category   Date 444  apple fruit 1-jan-2021 555   pear f...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous ,

     

    You could create a seperate year table.

    Table 2 = DISTINCT('Table'[Date].[Year])

     

    Two measure are created as

    Count Item ID = IF(ISFILTERED('Table 2'[Year]),CALCULATE(COUNT('Table'[Item ID]),FILTER('Table',YEAR([Date])=SELECTEDVALUE('Table 2'[Year]))),COUNT('Table'[Item ID]))
    Count Item ID(sameperiodlastyear) = IF(ISFILTERED('Table 2'[Year]), CALCULATE(COUNT('Table'[Item ID]),FILTER('Table',YEAR([Date])=SELECTEDVALUE('Table 2'[Year])-1)),COUNT('Table'[Item ID]))

     

     

    Best Regards,

    Stephen Tao

     

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