Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Sum the value and find max

Hello All,

 

I have a table as below.

OrderPartQTYYearDateBuyer
A00112345120201920190102ABC
A0011234550201920190212ABC
A0021234570201920190315DEF
A0011234650201920190115ABC
A0011234650201920190210ABC
A00312346150201920190312XYZ
A0031234650201920190210XYZ

 

I would like to see the Part number and Buyer for the Max Quantity(sum of rows for the Part number if multiple rows).

In short it should be 

Part      Buyer

12345   ABC - AS that buyer has max qty 120+50

12346   XYZ  

 

Thanks

 

  • Hi, Anonymous 

    Please check the below for creating a measure.

     

    Buyer Measure =
    IF (
    ISFILTERED ( 'Table'[Part] ),
    MAXX (
    FILTER (
    SUMMARIZE ( 'Table', 'Table'[Buyer], "@qtytotal", SUM ( 'Table'[QTY] ) ),
    [@qtytotal]
    = MAXX (
    GROUPBY (
    'Table',
    'Table'[Buyer],
    "@qty", SUMX ( CURRENTGROUP (), 'Table'[QTY] )
    ),
    [@qty]
    )
    ),
    'Table'[Buyer]
    )
    )

     

    Hi, My name is Jihwan Kim.

     

    If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

     

    Linkedin: linkedin.com/in/jihwankim1975/

    Twitter: twitter.com/Jihwan_JHKIM

  • Buyer Max = 
    MAXX( TOPN( 1, DISTINCT( Sales[Buyer] ), CALCULATE( SUM( Sales[QTY] ) ) ), Sales[Buyer] )

    bonus

    Buyer Min = 
    MAXX( TOPN( 1, DISTINCT( Sales[Buyer] ), CALCULATE( SUM( Sales[QTY] ) ), 1 ), Sales[Buyer] )

4 Replies

  • Hi, Anonymous 

    Please check the below for creating a measure.

     

    Buyer Measure =
    IF (
    ISFILTERED ( 'Table'[Part] ),
    MAXX (
    FILTER (
    SUMMARIZE ( 'Table', 'Table'[Buyer], "@qtytotal", SUM ( 'Table'[QTY] ) ),
    [@qtytotal]
    = MAXX (
    GROUPBY (
    'Table',
    'Table'[Buyer],
    "@qty", SUMX ( CURRENTGROUP (), 'Table'[QTY] )
    ),
    [@qty]
    )
    ),
    'Table'[Buyer]
    )
    )

     

    Hi, My name is Jihwan Kim.

     

    If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

     

    Linkedin: linkedin.com/in/jihwankim1975/

    Twitter: twitter.com/Jihwan_JHKIM

  • CNENFRNL's avatar
    CNENFRNL
    Icon for Community Champion rankCommunity Champion
    Buyer Max = 
    MAXX( TOPN( 1, DISTINCT( Sales[Buyer] ), CALCULATE( SUM( Sales[QTY] ) ) ), Sales[Buyer] )

    bonus

    Buyer Min = 
    MAXX( TOPN( 1, DISTINCT( Sales[Buyer] ), CALCULATE( SUM( Sales[QTY] ) ), 1 ), Sales[Buyer] )

  • v-henryk-mstf's avatar
    v-henryk-mstf
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

     

    For the solution provided by Jihwan_Kim , I did a test. Can also get the desired result.

     


    Best Regards,
    Henry

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

  • Anonymous's avatar
    Anonymous
    Not applicable

    CNENFRNL Jihwan_Kim Thanks for your help.Both of them worked and its just that i had to learn few things before putting them to use.