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
rauldip22
Frequent Visitor

How to select a top filtered value from a table with DAX

Hello!

I need a DAX consult to select a Gender with the max Amount from my table filtered by a Category.

With SQL ir should be: SELECT TOP 1 Gender FROM TableName WHERE Category = "A" ORDER BY Amount.

 

My Table is:

GenderAmountCategoryCases
Male6768768A6
Male344B8
Male44442C6
Male3344D5
Female7656A4
Female44577B3
Female334442C6
Female455D5

 

Thanks!!!!

1 ACCEPTED SOLUTION

@rauldip22

 

Or you can hardcode it for Category A as follows

 

Measure 2 =
TOPN (
    1,
    VALUES ( TableName[Gender] ),
    CALCULATE ( SUM ( TableName[Amount] ), TableName[Category] = "A" ), DESC
)

View solution in original post

3 REPLIES 3
Zubair_Muhammad
Community Champion
Community Champion

Hi @rauldip22

 

Try this MEASURE...It will give you the Gender with Highest Amount according to category or cases that you select

 

Measure =
TOPN (
    1,
    VALUES ( TableName[Gender] ),
    CALCULATE ( SUM ( TableName[Amount] ) ), DESC
)

@rauldip22

 

Or you can hardcode it for Category A as follows

 

Measure 2 =
TOPN (
    1,
    VALUES ( TableName[Gender] ),
    CALCULATE ( SUM ( TableName[Amount] ), TableName[Category] = "A" ), DESC
)

Thanks!!! It Works!

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.

Top Solution Authors
Top Kudoed Authors