Forum Discussion

yashkumarbhatia's avatar
yashkumarbhatia
Frequent Visitor
1 year ago
Solved

DAX

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 th...
  • Anonymous's avatar
    Anonymous
    1 year ago

    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.