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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
jerryr125
Helper III
Helper III

Display a description in a measure based upon a count of another variable

Hi again - I think I defined my requirements incorrectly.

 

Input:

Flavors-Sold-Data-Table

 

LocationFlavor
AVanilla
BStrawberry
BVanilla
AStrawberry
BStrawberry
BVanilla
BChocolate
AVanilla
AChocolate
AChocolate

 

I would like show the location with the maximum count of  flavor if the flavor is either Vanilla or Strawberry.

The output in the Measure I am looking for would be "B" since B has the highest count of the flavor Vanilla and Strawberry (4).

 

Any thoughts?

1 ACCEPTED SOLUTION

Var tbl =

Addcolumns(

All(Table),

"@cnt",

Calculate(

Countrows( table ),

Table[flavor] in {"vanilla", "strawberry"}

)

)

Return

Max(

Topn( 1, tbl, [@cnt], desc),

[@cnt]

)

 

Not sure about the button part


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

5 REPLIES 5
jerryr125
Helper III
Helper III

HI - This is working - thank you.

Question - what if I want to have a seperate measure showing the number (in this case 4).

 

Also, how can I set up image button (like click here for more details) that will go to another page of the table data and only show those four records  ?

max count  = 
var a = SUMMARIZE(filter('Table',[Flavor] in {"Vanilla","Strawberry"}),[Location],"ct",COUNTROWS('Table'))
return MAXX(a,[ct])

 

The button would have to be tied to a sort of filter (bookmark) to be efficient. Otherwise you could just add a static table, and you would need to define what you mean by "more details"

Var tbl =

Addcolumns(

All(Table),

"@cnt",

Calculate(

Countrows( table ),

Table[flavor] in {"vanilla", "strawberry"}

)

)

Return

Max(

Topn( 1, tbl, [@cnt], desc),

[@cnt]

)

 

Not sure about the button part


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
Deku
Super User
Super User

Var tbl =

Addcolumns(

All(Table),

"@cnt",

Calculate(

Countrows( table ),

Table[flavor] in {"vanilla", "strawberry"}

)

)

Return

Max(

Topn( 1, tbl, [@cnt], desc),

Table[location]

)

 


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
lbendlin
Super User
Super User

lbendlin_0-1744116879515.png

 

max count location = 
var a = SUMMARIZE(filter('Table',[Flavor] in {"Vanilla","Strawberry"}),[Location],"ct",COUNTROWS('Table'))
return CONCATENATEX(TOPN(1,a,[ct]),[Location])

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 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.