Forum Discussion
DanCasSan
Helper V
6 years agoRow_Number in column with DAX
Dear community: I need your support. I want to perform an equivalency of the SQL ROW_NUMBER function on one of my tables in Power BI; basically, do what I put in the image. This equivalence shoul...
- 6 years ago
Hi DanCasSan ,
You can add an index column in query editor first.
Then use the rankx function to create the calculated column.
Rank = RANKX ( FILTER ( 'Table', 'Table'[KEYRATE] = EARLIER ( 'Table'[KEYRATE] ) && 'Table'[PRDLIT] = EARLIER ( 'Table'[PRDLIT] ) ), 'Table'[Index], , ASC )Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
edhans
Community Champion
6 years agoI'm not aware of a way to put an index in a column in DAX. without a unique value to sort on. In Power Query, you just use the Add Column ribbon, then Index Column.
if you can rank your data and create an index that way, see this post
The problem is your data doesn't have a unique field, and row numbers aren't really a concept in a DAX table like they can be in SQL or Power Query.