Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Here is my dummy table
Product | Returned Sequence | Number | Price | Rank | wanted Rank | |
A | 1 | 121 | 400€ | 1 | 1 | |
A | 2 | 150 | 0€ | |||
A | 3 | 892 | 0€ | |||
A | 4 | 563 | 0€ | |||
A | 5 | 892 | 700€ | 5 | 2 | |
A | 5 | 892 | 1000€ | 5 | 2 | |
A | 5 | 892 | 100€ | 5 | 2 | |
B | 1 | 801 | 100€ | 1 | 1 | |
B | 1 | 801 | 5000€ | 1 | 1 | |
B | 2 | 653 | 0€ | |||
B | 3 | 788 | 300€ | 3 | 2 | |
B | 3 | 788 | 0€ |
I calculated the Rank Column with:
Rank = IF(Table1[Cost] <> 0, RANKX(FILTER(Table1, Table1[Product] = EARLIER(Table1[Product])), Table1[Returned Sequence],, ASC, Dense))
Is there any other formula/workaround to get the rank like in the wanted rank column? Thank you!
Solved! Go to Solution.
Hi @salfa_an
Here are a couple of options:
1. Modify your original expression to ensure Cost <> 0 within FILTER:
Rank 2 =
IF (
Table1[Cost] <> 0,
RANKX (
FILTER (
Table1,
Table1[Product]
= EARLIER ( Table1[Product] )
&& Table1[Cost] <> 0
),
Table1[Returned Sequence],
,
ASC,
DENSE
)
)
2. Rank over a table of distinct values of Returned Sequence, created using CALCULATETABLE:
Rank 3 =
IF (
Table1[Cost] <> 0,
VAR RankingTable =
CALCULATETABLE (
VALUES ( Table1[Returned Sequence] ),
ALLEXCEPT ( Table1, Table1[Product] ),
Table1[Cost] <> 0
)
RETURN
RANKX (
RankingTable,
Table1[Returned Sequence],
,
ASC
)
)
Do these work for you?
Regards
Hi @salfa_an
Here are a couple of options:
1. Modify your original expression to ensure Cost <> 0 within FILTER:
Rank 2 =
IF (
Table1[Cost] <> 0,
RANKX (
FILTER (
Table1,
Table1[Product]
= EARLIER ( Table1[Product] )
&& Table1[Cost] <> 0
),
Table1[Returned Sequence],
,
ASC,
DENSE
)
)
2. Rank over a table of distinct values of Returned Sequence, created using CALCULATETABLE:
Rank 3 =
IF (
Table1[Cost] <> 0,
VAR RankingTable =
CALCULATETABLE (
VALUES ( Table1[Returned Sequence] ),
ALLEXCEPT ( Table1, Table1[Product] ),
Table1[Cost] <> 0
)
RETURN
RANKX (
RankingTable,
Table1[Returned Sequence],
,
ASC
)
)
Do these work for you?
Regards
User | Count |
---|---|
25 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
27 | |
13 | |
11 | |
9 | |
6 |