Power BI topn function: Problem with topn function returning more than n rows due to duplicates

3.3k views Asked by At

This is the current data table that I have, which is called 'Potential High Usage' CLICK TO SEE DATA TABLE

I tried to use the TOPN function to create a table of the top 10 'User ID' based on the 'Number of clicks'. This is how I tried to do it:

High Usage IDs = topn(10,'Potential High Usage',[Number of clicks])

The problem is that it returns 11 rows instead of 10. I am thinking that its because I have many duplicates for the least number of clicks that will still be considered as top 10 (Number of clicks = 2). I was wondering if there is a way to return ONLY 10 rows?

2

There are 2 answers

1
Ashok Anumula On

Yes. TOPN will return more than N rows when there are ties at Nth row. See the Microsoft TOPN dax function documentation.enter image description here

4
Ashok Anumula On

First add index column using power query. Then use following DAX to return top 10 rows. enter image description here