Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

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.

johnbasha33_0-1625651253279.png

@amitchandak @Anonymous @dax @Pragati11 @superDAX @EDW 

1 ACCEPTED SOLUTION

@Anonymous , sorry my mistake, Try like

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

daxer_0-1625655506929.png

daxer_1-1625655570985.pngdaxer_2-1625655627845.png

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( )
    )
)
amitchandak
Super User
Super User

@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)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak , thanks for your time.

i tried that measure but not working as we want.

johnbasha33_0-1625653347777.png

 

@Anonymous , sorry my mistake, Try like

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

It worked @amitchandak  thank you.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.