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
cst_dev32
Frequent Visitor

Display TOP N by Count base on 1 Field

Hy guys, i have an issue for my work

I have 1 column named PLNT and I need to display top 5 from that column base on their count

here's the data

 

2.PNG

The PLNT and the CountThe PLNT and the Count

And i filter by PLNT count

 

Filter TOP 5 base on PLNT CountFilter TOP 5 base on PLNT CountBut the result showing 6 data not 5

The resultThe resultI just want to showing 5 PLNT not 6, how do it works?

1 ACCEPTED SOLUTION

@cst_dev32

 

You can achive this in two ways

 

1st way: which already provide in above...

 

1.  go to menu bar select "Edit Queries"

2.  go add column "index column" 

3.  select "From 1" in index column

 

like below

 

Index-Rank-menu.jpgIndex-Rank-index.jpg

 

2nd way: (If not available power query editor)

 

1. create one column for count

 

index = CALCULATE(COUNT('Rank'[Plant]), FILTER('Rank', 'Rank'[Plant] = EARLIER('Rank'[Plant])))

 

2. create quick measure for running total

 

index running total in Plant =
CALCULATE(
SUM('Rank'[index]),
FILTER(
ALLSELECTED('Rank'[Plant]),
ISONORAFTER('Rank'[Plant], MAX('Rank'[Plant]), DESC)
)
)

 

3. take "index running total in Plant" into visual filter chose <6

 

 

Index-Rank-running total.jpg

 

 

if it is solution for your query, please accept as solution...

 

 

View solution in original post

4 REPLIES 4
venug20
Resolver I
Resolver I

@cst_dev32

 

you can achive by this way... it may helps... you can try....

 

Steps:

 

1. create index column

2. take index column into visual filter

3. you can choose your number in filter... then apply

 

Index-Rank.jpgIndex-Rank-Filter.jpgIndex-Rank-Results.jpg

 

 

If it is solution to your query. Please accept as a soluiton... it will helps to others....

 

 

 

 

Hy @venug20

Thanks for reply my question

Can you tell me how to create the column index like that?

I just create the new calculate table like this5.PNG

 

 

but i stuck on creating index like you did

can you show me the formula?

thanks

 

FYI : I use direct query, so i can't use edit queries

@cst_dev32

 

You can achive this in two ways

 

1st way: which already provide in above...

 

1.  go to menu bar select "Edit Queries"

2.  go add column "index column" 

3.  select "From 1" in index column

 

like below

 

Index-Rank-menu.jpgIndex-Rank-index.jpg

 

2nd way: (If not available power query editor)

 

1. create one column for count

 

index = CALCULATE(COUNT('Rank'[Plant]), FILTER('Rank', 'Rank'[Plant] = EARLIER('Rank'[Plant])))

 

2. create quick measure for running total

 

index running total in Plant =
CALCULATE(
SUM('Rank'[index]),
FILTER(
ALLSELECTED('Rank'[Plant]),
ISONORAFTER('Rank'[Plant], MAX('Rank'[Plant]), DESC)
)
)

 

3. take "index running total in Plant" into visual filter chose <6

 

 

Index-Rank-running total.jpg

 

 

if it is solution for your query, please accept as solution...

 

 

TomMartens
Super User
Super User

Hey,

 

unfortunately this will not work using the TOPN filter from inside the visual, this is due to the tie,meaning the 4 PLNT with a value.

 

You have to decide which of the PLNT will not be selected, make this a business rule, create your own DAX and use this DAX statement to filter your data.

 

If you need help to create this DAX statement, please consider to provide a pbix file that contains sample data, upload the file to onedrive or dropbox and share the link.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

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.