Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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?
Solved! Go to Solution.
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!
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!
I'm getting this error.
@U156531
The ROWNUMBER function in DAX should work for you in this case: ROWNUMBER function (DAX) - DAX | Microsoft Learn
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
I tried
User | Count |
---|---|
85 | |
80 | |
77 | |
49 | |
41 |
User | Count |
---|---|
114 | |
56 | |
51 | |
42 | |
42 |