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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
vat2do
Helper III
Helper III

how to add index column in table/matrix visual

Hi Experts,

 

Is there a way to add an index column in power bi desktop's table/matrix visual which dont have filter affect while using filters for other columns.

 

Thanks in advance

1 ACCEPTED SOLUTION

Thanks all for providing your inputs, i have recently came across a solution, it uses visual calculation as below:

 

index = IF(

           ISATLEVEL([Quarter]),

           ROWNUMBER([year])

                 )

View solution in original post

10 REPLIES 10
Ashish_Mathur
Super User
Super User

Hi,

This measure should work

S. No. = ROWNUMBER(ALLSELECTED(Data),ORDERBY(Data[Date Presented]))

Data Presented is a column which you have dragged from the Data table into the visual.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi @vat2do,

Thanks for reaching out to the Microsoft fabric community forum. As @MarkLaf@ryan_mayu@Shahid12523 

and @FBergamaschi all have shared varied approaches depending on whether you want the index to be fixed at load-time or calculated inside the model. Kindly go through their responses and check the one that matches what your need.

 

I would also take a moment to thank @MarkLaf, @ryan_mayu, @Shahid12523 and @FBergamaschi, for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.

 

If I misunderstand your needs or you still have problems on it, please feel free to let us know.  

Best Regards,
Hammad.

Thanks all for providing your inputs, i have recently came across a solution, it uses visual calculation as below:

 

index = IF(

           ISATLEVEL([Quarter]),

           ROWNUMBER([year])

                 )

Anonymous
Not applicable

Hi @vat2do,

As we haven’t heard back from you, so just following up to our previous message. I'd like to confirm if you've successfully resolved this issue or if you need further help.

If yes, you are welcome to share your workaround so that other users can benefit as well.  And if you're still looking for guidance, feel free to give us an update, we’re here for you.

 

Best Regards,

Hammad.

MarkLaf
Super User
Super User

We probably need some sample data (pasted in as table that we cany easily copy) and a clear example output/behavior.

 

As a simple example that perhaps is along the lines of what you are looking for, consider the following table.

 

Example

Column1 Column2 Column3
1 A Z
1 A Z
1 B Z
2 B Z
2 C Z
2 C Y
3 D Y
3 D Y
3 E Y

 

If we want to add an index based on a certain sort of one of the columns that is not impacted by filters on the other columns, the RANK function may be the most straightforward to use.

 

For example, if we want an index based on Column2 (this would work as a measure or a calculated column):

 

Column2 Index = RANK( ORDERBY( Example[Column2], ASC ) )

 

MarkLaf_0-1756200955609.gif

Shahid12523
Community Champion
Community Champion

Option 1: Calculated Column (DAX, static)

 

Index = RANKX(ALL('YourTable'), 'YourTable'[UniqueID], , ASC, DENSE)


ALL() ensures it’s unaffected by filters.

 

Option 2: Power Query (static)

 

In Transform Data → Add Column → Index Column → From 1

Keeps a fixed index regardless of filters.

 

Option 3: Measure (dynamic, ignores slicers)

 

Index Measure = RANKX(ALL('YourTable'), 'YourTable'[UniqueID], , ASC, DENSE)

Shahed Shaikh
ryan_mayu
Super User
Super User

@vat2do 

We can Add an index column in Power Query (Add Column > Index Column).
This index is static, but when you filter your visual, the index will show the original row number for the filtered rows (not a continuous sequence).

 

If you want a dynamic row number that always starts at 1 for the visible rows:

 

Row Number =
RANKX(
ALLSELECTED('Table'),
[SortColumn],
,
ASC,
DENSE
)

 

if this does not work, pls provide some sample data and expected output.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks ryan,

I have already tried this measure but the output is all 1's not in series like 1,2,3,4...... (i need a dynamic index column )

@vat2do 

then you can try this

 

_rank =
CALCULATE(DISTINCTCOUNT('Table'[ID]),FILTER(ALLSELECTED('Table'[ID]),'Table'[ID]<=max('Table'[ID])))
11.png
12.png
 
pls see the attachment below




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




FBergamaschi
Solution Sage
Solution Sage

Hi @vat2do,

sure you can add an index column but in Power Query.

 

You can use the command here shown, after clicking on Transform Data in Power Bi Desktop and select the table on which you want to add it

 

FBergamaschi_0-1756196491546.png

 

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.

Top Solution Authors