DAX - Get current row number
问题 The question seems to be easy but I found it really hard to be done in DAX. I'd like to get the current row number on my current context data. Same as ROW_NUMBER() in T-SQL. Any hints? Thanks in advance. 回答1: There is no such function. Closest you can get is to calculate rank based on sort-order, like: DEFINE MEASURE SomeTbl[ROW_NO] = SUMX(SomeTbl, RANKX(ALL(SomeTbl), SomeTbl[SortCol])) EVALUATE ADDCOLUMNS(SomeTbl, "ROW_NO", SomeTbl[ROW_NO]) Or if you can't use RANKX EVALUATE ADDCOLUMNS (