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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Rigolleto
Resolver I
Resolver I

Add index using DAX

HI, I need help to create a sequence number as the photo shows,  notice that I have the color duplicate, that is correct, every color belong to a different Style, I need a DAX code to built the sequence and used it later in a calculation  Thanks

 

ImageForo.PNG

2 ACCEPTED SOLUTIONS
mahoneypat
Microsoft Employee
Microsoft Employee

You can do this in the query editor as is, but to do it with a DAX column you need another column that can be used to sort the color column (e.g., a date, a full table index).

 

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

Anonymous
Not applicable

Hi@Rigolleto

If you want to use DAX to meet your need, you have to create a new column and help you to sort it.

In my demo, I've created a column named “Group”.

Then you can try measure like this:

Index = RANKX(FILTER(ALL('Table'),'Table'[Color]=MAX('Table'[Color])),CALCULATE(MAX('Table'[Group])))

 

vcaitlynmstf_0-1627010266963.png

 

 

As a workaround:

It can also be achieved in the query editor, you can group on “Color” with operation "All Rows" ,then adjust the generated to have an Index added to the nested tables while grouping.

For details, please refer to the following video : NestedIndex in PowerBI

 

Here is the demo, please try it.

 

Hope it helps.

 

Best Regards,

Caitlyn Yan

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi@Rigolleto

If you want to use DAX to meet your need, you have to create a new column and help you to sort it.

In my demo, I've created a column named “Group”.

Then you can try measure like this:

Index = RANKX(FILTER(ALL('Table'),'Table'[Color]=MAX('Table'[Color])),CALCULATE(MAX('Table'[Group])))

 

vcaitlynmstf_0-1627010266963.png

 

 

As a workaround:

It can also be achieved in the query editor, you can group on “Color” with operation "All Rows" ,then adjust the generated to have an Index added to the nested tables while grouping.

For details, please refer to the following video : NestedIndex in PowerBI

 

Here is the demo, please try it.

 

Hope it helps.

 

Best Regards,

Caitlyn Yan

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

mahoneypat
Microsoft Employee
Microsoft Employee

You can do this in the query editor as is, but to do it with a DAX column you need another column that can be used to sort the color column (e.g., a date, a full table index).

 

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


Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.