Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

How to return the value in one column based on the highest value in another?

Probably a really easy question but I can't seem to figure it out.

 

My data source looks like this.

 

TABLE1

IDSITECUSTOMERITEMSPEND
11Aitem110
...............

 

I've made a visual in my report that looks like this:

 

CUSTOMERSUM OF SPEND
A40
B20
C100
D50
E220

 

I am trying to write a measure that returns the maximum spend based overall customers. So I want my output to be this.

 

CUSTOMERSUM OF SPENDMAX SPEND
A40220
B20220
C100220

D

50220

E

220220

 

I tried to do CALCULATE(MAX('TABLE1'[SPEND]), ALLSELECTED('TABLE1')) but this returns the highest spend line from TABLE1 not the highest sum of spend line from the visual like I want.

 

Anyone able to help me please?

 

Thank you.

  • Hi Anonymous ,

    Try this:

    Measure = MAXX( SUMMARIZE( ALLSELECTED(Table1) , Table1[Customer] , "Value" , SUM(Table[Spend]) ) [Value] )

2 Replies

  • tex628's avatar
    tex628
    Icon for Community Champion rankCommunity Champion

    Hi Anonymous ,

    Try this:

    Measure = MAXX( SUMMARIZE( ALLSELECTED(Table1) , Table1[Customer] , "Value" , SUM(Table[Spend]) ) [Value] )
    • Anonymous's avatar
      Anonymous
      Not applicable

      Worked perfectly thank you. I forgot the SUMMARIZE function.