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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Pbiuserr
Post Prodigy
Post Prodigy

Syntax issue with TOPN argument TABLE

Hello.
I have a measure which retrive name of category which has max [Change] value. I'd like to add another dimension to that - not only category, but also a gender and filter it to be female. so for instance out of gender (female), category 2 has max value, so output should be: category2

TOP cat name =
VAR _top_name = FIRSTNONBLANK(TOPN(1,VALUES(FctTable[Category]),[Change]),1)
RETURN
_top_name

it gives me name associated with max value when it concerns only one dimension - category. I'd like to add filter context of gender and only females Tried to ADDCOLUMNS inside TOPN but it didnt work.

Perhaps it should have other approach? Any ideas and tips are welcome
1 ACCEPTED SOLUTION

I've resolved my problem by using formula

 

CALCULATE( MAX(FctTable[Category]), TOPN(1, FILTER( SUMMARIZE (FctTable, FctTable[Gender], FctTable[Category], "@Chng", [Change]), FctTable[Gender] = "Female"), ABS([Change])) )

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Pbiuserr , Not very clear, check if one of the two can help

 

calculate(max(FctTable[Category]) ,TOPN(1,allselected(FctTable[Category]),[Change]), values(FctTable[Category]))

 

or

 

calculate([Change] ,TOPN(1,allselected(FctTable[Category]),[Change]), values(FctTable[Category]))

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

Hi Amit
I'd like to create such table virtually and retrive "Category" with max value for gender = "Female". "Change" is a measure, not column if it helps

Capture.PNG

I've resolved my problem by using formula

 

CALCULATE( MAX(FctTable[Category]), TOPN(1, FILTER( SUMMARIZE (FctTable, FctTable[Gender], FctTable[Category], "@Chng", [Change]), FctTable[Gender] = "Female"), ABS([Change])) )

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.