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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
)

Regards
Zubair

Please try my custom visuals

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
)

Regards
Zubair

Please try my custom visuals

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

Regards
Zubair

Please try my custom visuals

Thanks!!! It Works!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.