Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

max value for 2 categories

Hi All,

 

i am having hard time finding the max value product.

below is my table of data. for argentina 1336 is the max sold value and peripherals is the max sold item.

i am able to get the max sold value with this measure 

Maxvalue =
MAXX(
    KEEPFILTERS(VALUES(Sales[Product])),
    CALCULATE(SUM('Sales'[AMOUNT_SOLD]))
)
but i am unable to get the max sold item name which is peripherals i have tried many many dax functions but i am not able to get that. kindly help.
my ultimate result should be for each country one record with max sold item and its value.

amitchandak Anonymous dax Pragati11 superDAX EDW 

  • Anonymous , sorry my mistake, Try like

    Rankx(filter(allselected('Sales'[Country], 'Sales'[Product]),'Sales'[Country] =max('Sales'[Country])), CALCULATE(SUM('Sales'[AMOUNT_SOLD])),,desc)

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Max Amount Prod = 
    IF( not ISBLANK( [Total Amount] ),
        CALCULATE(
            MAX( T[Amount] ),
            VALUES( Country[Country] ),
            ALLSELECTED(  )
        )
    )
    
    Max Prod = 
    If( not ISBLANK( [Total Amount] ),
        var MaxProdAmount = [Max Amount Prod]
        return
        CALCULATE(
            MAXX(
                FILTER(
                    SUMMARIZE(
                        T,
                        Country[Country],
                        'Product'[Product]
                    ),
                    [Total Amount] = MaxProdAmount
                ),
                'Product'[Product]
            ),
            VALUES( Country[Country] ),
            ALLSELECTED( )
        )
    )
  • Anonymous , Based on what I got. Create a rank and apply visual filter for rank =1

     

    Rankx(allselected('Sales'[Country], 'Sales'[Product]), CALCULATE(SUM('Sales'[AMOUNT_SOLD])),,desc)

    • Anonymous's avatar
      Anonymous
      Not applicable

      amitchandak , thanks for your time.

      i tried that measure but not working as we want.

       

      • amitchandak's avatar
        amitchandak
        Super User

        Anonymous , sorry my mistake, Try like

        Rankx(filter(allselected('Sales'[Country], 'Sales'[Product]),'Sales'[Country] =max('Sales'[Country])), CALCULATE(SUM('Sales'[AMOUNT_SOLD])),,desc)