Forum Discussion
RANKX with ALLSELECTED AND ALLEXCEPT?
Hello,
I have one big datatable with the following columns
| Date | EAN | PD:PRODUCT EAN-Name | CATEGORY | LANGUAGE | VALIDID | RANDOM |
| 01.01.2020 | 123 | P1 | CARE | DE | x | 1 |
| 01.02.2020 | 1234 | P2 | SPECIAL CARE | CN | x | 1,5 |
| 07.01.2020 | 1234 | P2 | SPECIAL CARE | CN | x | 1,8 |
| 04.01.2020 | 123 | P1 | CARE | EN | x | 2 |
| 01.01.2020 | 12345 | P3 | SPECIAL CARE | CN | x | 1 |
VALIDID is a calculated column through which power BI decides what EAN is valid
I am using the following RANKX function:
4 Replies
- Greg_Deckler
Community Champion
Anonymous Just a thought, what if you created a second, duplicate measure and used that in your filter criteria instead of the same measure?
- AnonymousNot applicable
Thanks for the hint but this did not help. Can this have something to do with the filter I am using before loeading the data in to my model? Because before I am loading the data I am filtering out invalid rows through the category column within in the query view(Table tools)
- AnonymousNot applicable
Hi Anonymous ,
I won't suggest using the filter pane to do the top 5, when I do this in my dashboard, I will use:
measure = if(RANKX(ALLSELECTED('Data'[PD: Product EAN-Name]),[PRODUCTSCAN],,DESC) <= 5, RANKX(ALLSELECTED('Data'[PD: Product EAN-Name]),[PRODUCTSCAN],,DESC), blank())Then the table will show the top 5 automatically.
Please try.
Aiolos Zhao
- amitchandak
Super User
Anonymous ,
I think you have to add rand to rank
RANKING SCANNER = RANKX(ALLSELECTED('Data'[PD: Product EAN-Name]),[PRODUCTSCAN],,DESC) + rand()
and then use a visual level filter or Top N again on this
Refer how it works :https://www.youtube.com/watch?v=kRtmb8ftyQc