Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
crln-blue
Post Patron
Post Patron

Adding index number or row number in a summarized table

Hello!

 

I'm creating a summarized table and I need to have an index number or row number. Search results lead to having index number using the Power Query but in my case, I need to have a summarized table.

My summarized table is just like this:

CategoryIndex (I don't know how to have this)
A 
B 
C 
D 
E 

 

I tried this but I only get the same result:

crln-blue_0-1607632612946.png

 

Any help is appreciated. Thank you!

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

Please try this column expression.

 

CategoryIndex = RANKX(Category, Category[Category],,ASC)
 
Regards,
Pat




Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

7 REPLIES 7
mahoneypat
Employee
Employee

This would be done more easily in the query editor, but here is how to do it in a DAX table.  There probably is a way to do it in one table variable, but I used two to make it easier.  Replace with your actual table/column names.

 

New Table =
VAR table1 =
    ADDCOLUMNS (
        SUMMARIZE (
            Category,
            Category[Category],
            Category[Group]
        ),
        "merge",
            Category[Group] & Category[Category]
    )
VAR table2 =
    ADDCOLUMNS (
        SUMMARIZE (
            Category,
            Category[Category],
            Category[Group]
        ),
        "Rank",
            VAR thismerge = Category[Group] & Category[Category]
            RETURN
                COUNTROWS (
                    FILTER (
                        table1,
                        [merge] < thismerge
                    )
                ) + 1
    )
RETURN
    table2





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hello! How do you this in a DAX column? Thank you! I'm gonna use this for my hierarchy. Much thanks again!

mahoneypat
Employee
Employee

Not sure what you mean by summarized table.  Are you making a DAX table with SUMMARIZE?  Or do you mean a table visual with the Category and Group columns?  Please clarify.

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hello @mahoneypat !
Yes, I'm making a DAX table using the SUMMARIZE function. The above excel screenshot that I sent is my expected outcome from my DAX table. Thanks!

mahoneypat
Employee
Employee

Please try this column expression.

 

CategoryIndex = RANKX(Category, Category[Category],,ASC)
 
Regards,
Pat




Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Btw @mahoneypat , how do I add this during the summarized formulas? Also, can I add index numbers based on group?
For example: (for some reason, I can't attach a table so I provided a sample screeshot)

crln-blue_1-1607670849112.png

Thanks in advance!

Thank you!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.