Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
Hi,
While ranking using RANKX, is it posible to filter the transaction based on some criteria ?
I created a measure like this :
Rank =
VAR tmpVal = SUM('Transactions'[Item qty])
RETURN
IF(tmpVal = 0, BLANK(),
RANKX(
ALL('Products'[Item id]),
CALCULATE(
SUM('Transactions'[Item qty]),
'Products'[Product type] = 1
)
)
)The explanation to that, I put a filter inside the CALCULATE, for the transactions only for product with type = 1, which just some category inside my Product master.
But the result I get now is :
If I remove the filter of product type then it is correct.
Should I filter my Product as well ? it is seems odd, because if the transactions already filter, why they need to rank products which not in the transactions anyway.
Thanks,
You're not ranking transactions but products. And products have the types you mention, not transactions. It's not entirely clear what you're after since the description is misleading. Would you care to show what the correct output should look like, please? And please try to clarify your description.
Hi @daxer-almighty ,
I'm sorry, may I ask which one is not clear ? Maybe what a bit confusing is between "item id" and "product type code" ? item id is same like "product id", while "product type code" is another field inside my Product master, which use for a category, and right now I only want to rank products with type code =1 within my transactions.
For the correct / expected output, I think can refer to the image, I've sort the column "Item qty", so the rank should follow that order.
However, I tried to change the measure, to filter the Product instead like this :
Rank =
VAR tmpVal = SUM('Transactions'[Item qty])
RETURN
IF(tmpVal = 0, BLANK(),
RANKX(
FILTER(
ALL('Products'),
'Products'[Product type code] = 1
),
CALCULATE(
SUM('Transactions'[Item qty])
),,DESC,Dense
)
)It looks "correct" a bit, only there is one double rank like below:
Thanks
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 6 | |
| 6 | |
| 4 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 22 | |
| 10 | |
| 8 | |
| 7 | |
| 6 |