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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Trying to create a dynamic row number in a table visual

I need to add a Row number to one of my table visuals. I've created a unique index column in the underlying table. The index can be used to create a row number starting from Row 1. Unfortunately when I filter the table visual on the Year column the Row value no longer starts with row 1. Below is what is coming out in the table visual. Is there a way to define a dynamic row number so it always starts with a row 1 regardless of the filtering on the visual?

U156531_0-1741375014547.png

 

 

1 ACCEPTED SOLUTION
sevenhills
Super User
Super User

Two points if known, can provide accurate syntax.

 

Use case: you are trying to get the row number based on filter selection of each row. 

 

Assuming you have index column to identify unique row, then you can use this.

 

Try this:

Row_Number = 
CALCULATE (
    COUNTROWS('Table');
    FILTER ( ALLSELECTED ('Table'), 'Table'[Index] <= MAX ( 'Table'[Index]) )
)
 

 

Or  If not you can use all the filters that are applied to the table.

 

Row_Number = 
var _v1 = SELECTEDVALUE ( 'Table'[filterColumn1])
var _v2 = SELECTEDVALUE ( 'Table'[filterColumn2])
RETURN CALCULATE ( COUNTROWS('Table');
    FILTER ( ALLSELECTED ('Table'),
           'Table'[filterColumn1] <= _v1 && 'Table'[filterColumn2] = _v2 )
)

 

Hope this helps!

View solution in original post

6 REPLIES 6
sevenhills
Super User
Super User

Two points if known, can provide accurate syntax.

 

Use case: you are trying to get the row number based on filter selection of each row. 

 

Assuming you have index column to identify unique row, then you can use this.

 

Try this:

Row_Number = 
CALCULATE (
    COUNTROWS('Table');
    FILTER ( ALLSELECTED ('Table'), 'Table'[Index] <= MAX ( 'Table'[Index]) )
)
 

 

Or  If not you can use all the filters that are applied to the table.

 

Row_Number = 
var _v1 = SELECTEDVALUE ( 'Table'[filterColumn1])
var _v2 = SELECTEDVALUE ( 'Table'[filterColumn2])
RETURN CALCULATE ( COUNTROWS('Table');
    FILTER ( ALLSELECTED ('Table'),
           'Table'[filterColumn1] <= _v1 && 'Table'[filterColumn2] = _v2 )
)

 

Hope this helps!

Just to add some samples:

Using selected values as guidance:

sevenhills_0-1741634970270.png
Using Index (as guidance):
sevenhills_1-1741635005656.png

Default output:

sevenhills_2-1741635068416.png

Selected filter output:

sevenhills_4-1741635155007.png

 


Is this what you are looking for ? Hope this helps!

Ashish_Mathur
Super User
Super User

Hi,

See if my solution in this file helps.


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

I'm getting this error.

S. No. = ROWNUMBER(ALLSELECTED('C-Standard Revisions'),ORDERBY('c-standard Revisions'[BOOK_DATE]))

U156531_0-1741615236211.png

 

Fowmy
Super User
Super User

@Anonymous 

The ROWNUMBER function in DAX should work for you in this case: ROWNUMBER function (DAX) - DAX | Microsoft Learn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

I tried 

Row = ROWNUMBER('Table_name')  The Tabe_name is the table behind the visual. Unfortunaely it only returns the value 1 for each row. 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.