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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jraward
New Member

Top N showing more than N

I'm having a brain failure at the moment and I can't quite figure out the logic behind how BI determines the Top N from a list with some duplicates:

 

 

 

Can someone explain how there are 4, when I've asked for the top 3 and there are only 2 distinct values there; 11 & 5?

 

I assume it's because there are 3 distinct 'location' properties, but this doesn't make sense to me when I've only asked for top 3 Fruit by Qty

2 ACCEPTED SOLUTIONS

@jraward It is expected behavior based on the TOPN DAX function:

"If there is a tie, in order_by values, at the N-th row of the table, then all tied rows are returned. Then, when there are ties at the N-th row the function might return more than n rows."

 

source: https://msdn.microsoft.com/en-us/library/gg492198.aspx


Looking for more Power BI tips, tricks & tools? Check out PowerBI.tips the site I co-own with Mike Carlo. Also, if you are near SE WI? Join our PUG Milwaukee Brew City PUG

View solution in original post

v-ljerr-msft
Employee
Employee

Hi @jraward,


Can someone explain how there are 4, when I've asked for the top 3 and there are only 2 distinct values there; 11 & 5?

 

I assume it's because there are 3 distinct 'location' properties, but this doesn't make sense to me when I've only asked for top 3 Fruit by Qty 

Eno1978 has already given a good explanation on the behavior of TopN filter. I would like to explain it a little more precisely against your example above.Smiley Happy

 

In your example, you ask for the top 3 Fruit by Qty, so the top 3 Qty should be(11, 11, 5), but there is a tie for 3rd Qty(both olives and lychee have the same Qty of 5), so what to do? Which Fruit should be the third one, olives or lychee? The TopN doesn't know.Smiley Very Happy So both olives and lychee will be return for the 3rd Qty. And that's why there're four furits returned.

 

Regards

View solution in original post

2 REPLIES 2
v-ljerr-msft
Employee
Employee

Hi @jraward,


Can someone explain how there are 4, when I've asked for the top 3 and there are only 2 distinct values there; 11 & 5?

 

I assume it's because there are 3 distinct 'location' properties, but this doesn't make sense to me when I've only asked for top 3 Fruit by Qty 

Eno1978 has already given a good explanation on the behavior of TopN filter. I would like to explain it a little more precisely against your example above.Smiley Happy

 

In your example, you ask for the top 3 Fruit by Qty, so the top 3 Qty should be(11, 11, 5), but there is a tie for 3rd Qty(both olives and lychee have the same Qty of 5), so what to do? Which Fruit should be the third one, olives or lychee? The TopN doesn't know.Smiley Very Happy So both olives and lychee will be return for the 3rd Qty. And that's why there're four furits returned.

 

Regards

@jraward It is expected behavior based on the TOPN DAX function:

"If there is a tie, in order_by values, at the N-th row of the table, then all tied rows are returned. Then, when there are ties at the N-th row the function might return more than n rows."

 

source: https://msdn.microsoft.com/en-us/library/gg492198.aspx


Looking for more Power BI tips, tricks & tools? Check out PowerBI.tips the site I co-own with Mike Carlo. Also, if you are near SE WI? Join our PUG Milwaukee Brew City PUG

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors