Forum Discussion

syelify's avatar
syelify
Frequent Visitor
2 years ago
Solved

Calculate the max value by category

I have this table (left) and showing the result should be.

It will sum all the maximum shelves w

 

Any help will appreciated, thanks in advance!

 

  • Thank you, would it be possible to have the Dax measure

  • create two columns

    month = FORMAT('Table'[Date],"mmm")
    shelves2 = if('Table'[Shelves]=CALCULATE(max('Table'[Shelves]),ALLEXCEPT('Table','Table'[month],'Table'[Door])),'Table'[Shelves],0)
     
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi syelify 

     

    Thanks to ryan_mayu  for your timely and effective response, here are my additions:

     

    You can create two measures as follow.

    max = 
    VAR _month = MONTH(MAX([Date]))
    VAR _max = CALCULATE(MAX([Shelves]), FILTER(ALLEXCEPT('Table', 'Table'[Door]), MONTH([Date]) = _month))
    RETURN
    _max

     

    sum = CALCULATE(SUM('Table'[Shelves]), FILTER('Table', [Shelves] = [max]))

     

    Change Date to a hierarchical structure

     

    Output:

     

    Best Regards,
    Yulia Xu

     

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

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi syelify 

     

    Thanks to ryan_mayu  for your timely and effective response, here are my additions:

     

    You can create two measures as follow.

    max = 
    VAR _month = MONTH(MAX([Date]))
    VAR _max = CALCULATE(MAX([Shelves]), FILTER(ALLEXCEPT('Table', 'Table'[Door]), MONTH([Date]) = _month))
    RETURN
    _max

     

    sum = CALCULATE(SUM('Table'[Shelves]), FILTER('Table', [Shelves] = [max]))

     

    Change Date to a hierarchical structure

     

    Output:

     

    Best Regards,
    Yulia Xu

     

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

  • syelify's avatar
    syelify
    Frequent Visitor

    Thank you, would it be possible to have the Dax measure

    • ryan_mayu's avatar
      ryan_mayu
      Icon for Super User rankSuper User

      create two columns

      month = FORMAT('Table'[Date],"mmm")
      shelves2 = if('Table'[Shelves]=CALCULATE(max('Table'[Shelves]),ALLEXCEPT('Table','Table'[month],'Table'[Door])),'Table'[Shelves],0)