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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.