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
Dushatar
New Member

Filter by top N on custom measure not working as intended.

I have two fields "Success" and "Fail" that count the number of Succeeded/Failed tasks for companies. For example a company might have 5 Succeeded and 5 Failed tasks. I wanted to make two graphs to show the % of success and fail for each company, and since they either succeed or fail I made two measures as follows:

 

%Success = count(Success) /  (count(Success)+count(Fail))

%Fail = count(Fail) /  (count(Success)+count(Fail))

 

I then put them in two graphs, with Y axis the % and Y axis the company. They give the correct %, so far so good.

 

However I want to show only the top 10 companies by percentage, so I put a filter top N = 10 by value "%Success" on one and "%Fail" on the other. For the %Fail graph this works just as intended, giving me the top 10 result with highest %Fail. However when doing exactly the same for %Success it instead of taking top N highest %, it takes the top N highest count (number of succeeded tasks).

 

This means a company that has 10 Success and 90 Fails (making it just 10%) will be shown before a company that have only 1 success but no fail (making it 100%).

 

I am confused why it works different for the two graphs when I have set them up exactly the same, and the measure is calculated the same way. 

 

This becomes evident as if I sort top 10, there will be two in the top with 100% and then the third place at 93%, but if I then increase to top 20, I suddenly have a lot of new companies at 100% that were previously now shown because they had fewer # than the others with lower %. 

 

Bugg top N.png

 

And again, this works for the %Fail graph. It has four with 100% in the top 10, and if I switch to top 20, the top 10 remains the same as they were already top ranked by % (but not being by number). 

1 ACCEPTED SOLUTION

Hello, thanks for the suggestion.

 

I finally solved the problem, sadly before I read your suggestion so I am not sure if that would have helped too. My problem was due to the ACCOUNTNUM the filter was on top of having issues on its own, after I switched to another filter it worked as intended. 

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Dushatar , is % Automated a measure? It should be measure not column

 

Try TOP N function and check

 

CALCULATE( [% Automated] ,TOPN(10,allselected('Table'[AccountNUM]), [% Automated] ,DESC),values('Table'[AccountNUM]))

 

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

Hello, thanks for the suggestion.

 

I finally solved the problem, sadly before I read your suggestion so I am not sure if that would have helped too. My problem was due to the ACCOUNTNUM the filter was on top of having issues on its own, after I switched to another filter it worked as intended. 

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.