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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
JimSales81
Helper I
Helper I

Show count of a category in a dynamic top N model

Hello,

I successfully created a dynamic Top N model in Power BI using the following data

 

'Sales' Table
SalespersonUnits SoldRegion
Jim20West
Kelly18West
Roger17East
Pam15East
Sally12West
Tom9East
Mike8West
Joe7East
Steve5West
Lauren3East

 

1.) Created a table called 'TOPN Selection'
Top N
3
5
8
10

 

2.) Created a measure called Selected N=

Selected N = SELECTEDVALUE('TOPN Selection'[Top N])
 
3.) Created a Units Rank Calculated Column
Unit Rank = rankx(Sales, Sales[Units Sold], , DEsc)
 
4.) Created a slicer Control
Slicer Control = var SelectedTop=Selectedvalue('TopN Selection'[Top N])
Return
if(SELECTEDVALUE(Sales[Unit Rank])<=SelectedTop, 1, 0)
 
5.) Added the Slicer control as a filter and selected is 1
 
It works great.  But what i want to do is add a card visual that shows the count of  West Salespeople dependent on the Top N selection
 
So when Top 3 is Selected my Card visual will say 2 (Jim & Kelly)
When Top 5 is Selected it will say 3 (Jim, Kelly, & Sally)
When Top 8 is Selected it will say 4 (Jim, Kelly, Sally, & Mike)
When Top 10 is Selected it will say 5 (Jim, Kelly, Sally, Mike, & Steve)
 
I can't figure out the dax.  Please advise.

Thank you!
1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1710477973998.png

 

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1710477973998.png

 

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Jihwan_Kim,

 

THis is perfect.  Similarly how would i write a measure to get the Total Units sold by Salespeople in the west based on the top N selection.

So if 3 was selected the total units sold in the west would be 38 but if 5 was selected it would change to 50, etc.

Hi,

thank you for your message, and please check the attached pbix file.

 

Jihwan_Kim_0-1710565707359.png

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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