Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreThe FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now
We need to provide rank. The logic for the ranking is that whenever you have a value “Product” then you must start the new number and all others below should follow the same rank. Please check out the sample input and the expected output. Please provide or help me with the DAX to use
Solved! Go to Solution.
Thanks for 123abc's concern about this issue.
Hi, @yashkumarbhatia
I am glad to help you.
Based on your description, you need a ranking of the data that whenever you have a value "Product" then you must start the new number and all others below should follow the same rank.
Maybe you can refer to my DAX.
New Column in Power BI Desktop:
RNK =
VAR CurrentRow = Table1[ID]
VAR RNKVal =
CALCULATE(
COUNTROWS(Table1),
FILTER(
Table1,
Table1[ID] <= CurrentRow && Table1[Vals] = "Product"
)
)
RETURN RNKVal
Here is the result:
I have attached the corresponding pbix file below, I hope it helps you.
I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks for 123abc's concern about this issue.
Hi, @yashkumarbhatia
I am glad to help you.
Based on your description, you need a ranking of the data that whenever you have a value "Product" then you must start the new number and all others below should follow the same rank.
Maybe you can refer to my DAX.
New Column in Power BI Desktop:
RNK =
VAR CurrentRow = Table1[ID]
VAR RNKVal =
CALCULATE(
COUNTROWS(Table1),
FILTER(
Table1,
Table1[ID] <= CurrentRow && Table1[Vals] = "Product"
)
)
RETURN RNKVal
Here is the result:
I have attached the corresponding pbix file below, I hope it helps you.
I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
To create a ranking based on the "Product" column as per your logic in Power BI, where a new rank starts whenever "Product" appears, you can use a DAX formula to generate this custom ranking.
Here's a sample approach:
Row Product
| 1 | A |
| 2 | |
| 3 | |
| 4 | B |
| 5 | |
| 6 | C |
| 7 |
Row Product Rank
| 1 | A | 1 |
| 2 | 1 | |
| 3 | 1 | |
| 4 | B | 2 |
| 5 | 2 | |
| 6 | C | 3 |
| 7 | 3 |
Please write the DAx in and aaranged manner and the output after writing this is please help @123abc
I can see that you're trying to assign a ranking to values in the "Vals" column. The requirement is to reset the rank every time a "Product" entry appears. I will provide a more detailed and organized DAX approach to achieve this.
Here is a step-by-step guide to writing the DAX measure for this case:
Rank =
VAR CurrentRow = Table[ID]
VAR IsProduct = Table[Vals] = "Product"
RETURN
IF(
IsProduct,
RANKX(
FILTER(Table, Table[ID] <= CurrentRow && Table[Vals] = "Product"),
Table[ID],
, ASC
),
CALCULATE(
MAXX(
FILTER(Table, Table[ID] < CurrentRow && Table[Vals] = "Product"),
RANKX(FILTER(Table, Table[ID] <= CurrentRow && Table[Vals] = "Product"), Table[ID], , ASC)
)
)
)
| 1 | Product | 1 |
| 2 | Milk | 1 |
| 3 | Butter | 1 |
| 4 | Cheese | 1 |
| 5 | Yogurt | 1 |
| 6 | Product | 2 |
| 7 | Muesli | 2 |
| 8 | Porridge | 2 |
| 9 | Product | 3 |
| 10 | Banana | 3 |
This approach should generate the expected output, where each "Product" starts a new rank, and all other values below it follow the same rank until a new "Product" appears.
Let me know if this resolves the issue!
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.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 53 | |
| 40 | |
| 38 | |
| 19 | |
| 18 |
| User | Count |
|---|---|
| 70 | |
| 69 | |
| 34 | |
| 33 | |
| 30 |