Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Compare latest values

Hello, 
I have a table like this 

CategoryWeekValue
C11aaa
C12ccc
C21bbb

 

How do I create a filter that sums the latest value per category
(in this case that would mean bbb + ccc)
Thanks!

  • Anonymous 

     

    Please find the DAX as below

    Latest Week Value = if( CALCULATE(max(Category[Week]),all(Category),Category[Category]=max(Category[Category]))=max(Category[Week]),sum(Category[Value]),0)

     

    Regards,
    Ritesh

4 Replies

  • Anonymous 

     

    Please find the DAX as below

    Latest Week Value = if( CALCULATE(max(Category[Week]),all(Category),Category[Category]=max(Category[Category]))=max(Category[Week]),sum(Category[Value]),0)

     

    Regards,
    Ritesh
    • Anonymous's avatar
      Anonymous
      Not applicable

      What happens if the latest value is not the same as the maximum value?

  • Anonymous  formula is as per the latest week value within the category, you want that only?

     

    max(Category[Week]),all(Category),Category[Category]=max(Category[Category]))=max(Category[Week])

     

    LHS > This will get you the Latest Week within category =     RHS > This is at row level context, max is used to make it an aggregate otherwise it will give you the Category Week per row

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you so much for the help 🙂