Forum Discussion
Trying to create a dynamic row number in a table visual
- 1 year ago
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!
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!
- sevenhills1 year ago
Super User
Just to add some samples:
Using selected values as guidance:
Using Index (as guidance):Default output:
Selected filter output:
Is this what you are looking for ? Hope this helps!