Hello,
I am trying to figure out how to add a virtual number to each row of data, but NOT for tracking or a unique id but just visual tracking when looking at the data. Pretty much the same type of row numbering from Google sheets/Excel that is already built in.
Google Sheet Example:
Solved! Go to Solution.
Your data source's row numbers are what's referenced by the [_ROWNUMBER] column. You can't change that from your app.
It sounds like you're looking to display something like a dynamic index number. You would need to contrive an expression that counts the rows up to the current row. Here's a way to do that. You would need to substitute [_ROWNUMBER] with whatever expression filters and sorts your data. Even then, you might have challenges if multiple rows have identical values using in sorting (e.g., there might not be an easy way to generate different index numbers for each "Smith" in a list alphabetized by surname).
COUNT(SELECT(MyTable[KeyColumn], [_RowNumber] <= [_THISROW].[_RowNumber]))
If you are showing this in the unfiltered tables, there is a[_RowNumber] column you can use. It is not shown by default so you would need to turn "on" the Show property.
It starts the count at 2, is there a way to start it at 1?
It starts the count at 2, is there a way to start it at 1? Or just count the rows
@hartable wrote:It starts the count at 2
It's just showing you the actual row number from the data source--not starting or counting anything. If you need it, you could create a virtual column that transforms the number. For example:
[_ROWNUMBER] - 1
As @WillowMobileSys alluded to, in any approach utilizing the values from the [_ROWNUMBER] column you won't end up with consecutive numbers if you filter or sort the table in your view.
Thank you both!
Last question: If I want the row numbers to be independent of the data, so when a sort is done, the row numbers stay the same, but the data is still able to be updated, removed, or reordered.
Like if you delete or move a row in a spreadsheet and move the rest of the columns up row numbers order stays the same and everything else changes.
Your data source's row numbers are what's referenced by the [_ROWNUMBER] column. You can't change that from your app.
It sounds like you're looking to display something like a dynamic index number. You would need to contrive an expression that counts the rows up to the current row. Here's a way to do that. You would need to substitute [_ROWNUMBER] with whatever expression filters and sorts your data. Even then, you might have challenges if multiple rows have identical values using in sorting (e.g., there might not be an easy way to generate different index numbers for each "Smith" in a list alphabetized by surname).
COUNT(SELECT(MyTable[KeyColumn], [_RowNumber] <= [_THISROW].[_RowNumber]))
Okay, so pretty much there is no way to keep the row numbers static when someone sorts, and everything else move. But I can count the rows dynamically as the app gets updated.
Now is there a way to freeze this column?
This row wouldn't meet the criteria to auto trigger "First column represents the key or label of the table ". Has a manual way to freeze them been developed yet?
@hartable wrote:Has a manual way to freeze them been developed yet?
Nope.
User | Count |
---|---|
36 | |
8 | |
3 | |
2 | |
2 |