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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Charline_74
Helper III
Helper III

Having an index column in a visual table

Hi
On my Power BI report, I have a visual table that fetches columns from several tables.

And I'd like to create an index in this visual but I don't know how to do it?

Does anyone have a solution?

Best regards

1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@Charline_74 , You can create a column or measure using RANKX function

 

For calculated column

Index = RANKX(ALL('Sales'), 'Sales'[OrderDate], , ASC, DENSE)

 

For measure

IndexMeasure =
VAR CurrentRow = MAX('Sales'[OrderDate])
RETURN
RANKX(ALL('Sales'), 'Sales'[OrderDate], CurrentRow, ASC, DENSE)

 




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

Proud to be a Super User!




LinkedIn






View solution in original post

6 REPLIES 6
shafiz_p
Resident Rockstar
Resident Rockstar

Hi, @Charline_74  If you don't have column with unique values, and have multiple columns in the table, then you can use rownumber function to create index column with a combination of all the columns in your table. For example,

Index =
ROWNUMBER(ALLSELECTED('Table'[Column1], 'Table'[Column2], 'Table'[Column3], 'Table'[Column4]))

Basically Dax don't have any exact function to create index column. You must need to have a column with unique values first then using RANKX function you are able to create index.

It is always better to create index column in power query editor.

Hope this helps!!

If this solved your problem, please mark it as a solution!!
Charline_74
Helper III
Helper III

@bhanu_gautam & @manvishah17 
how do I do this when none of my columns contains unique data?

Here's the result I got :

Charline_74_0-1721124249919.png

 

You can merge two column using concat and create some unique values if possible in your table




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

Proud to be a Super User!




LinkedIn






@bhanu_gautam : I don't have that option 

 

bhanu_gautam
Super User
Super User

@Charline_74 , You can create a column or measure using RANKX function

 

For calculated column

Index = RANKX(ALL('Sales'), 'Sales'[OrderDate], , ASC, DENSE)

 

For measure

IndexMeasure =
VAR CurrentRow = MAX('Sales'[OrderDate])
RETURN
RANKX(ALL('Sales'), 'Sales'[OrderDate], CurrentRow, ASC, DENSE)

 




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

Proud to be a Super User!




LinkedIn






manvishah17
Responsive Resident
Responsive Resident

Hi @Charline_74 ,
Using Power Query Editor:

  1. Open Power Query Editor: Go to Home > Transform data.
  2. Add Index Column: Select the table, then Add Column > Index Column > Choose From 0 or From 1.
  3. Apply Changes: Click Close & Apply.
  4. Use Index: Drag the index column into your visual table.

Using DAX:

  1. Create Calculated Column: Go to Modeling > New Column, and use:
    Index = RANKX(ALL('YourTable'), 'YourTable'[ColumnToOrderBy], , ASC, Dense)
  2. Use Index: Add the new index column to your visual table.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.