Forum Discussion
How can I create a simple index column with dax.
- 7 years ago
Yep it works. Thanks
- 6 years ago
gtamir - Oh, then you want my SuperRank column formula, which I just invented:
SuperRank = VAR __table = FILTER(ALL('Table6'),[Total] > EARLIER('Table6'[Total])) VAR __tableSame = FILTER(ALL('Table6'),[Total] = EARLIER('Table6'[Total]) && [Customer] < EARLIER(Table6[Customer])) RETURN COUNTROWS(__table) + 1 + COUNTROWS(__tableSame)Attaching PBIX, you want Table6.
- 6 years ago
gtamir That is correct as written. You have to have some secondary identifier, you cannot just magically assign the ranks when things tie. You could use actual Index column in your query and then use that as your secondary identifier and that would ensure that you would never get the same rank twice.
See if this solution helps:
https://community.powerbi.com/t5/Desktop/Add-calculated-index-column-by-DAX/td-p/72448
To my understanding it is a Rank. I want a simple index 1 up to the last row.
I'd like to have this:
- Greg_Deckler7 years ago
Community Champion
Oh, well that's super easy, you just need to add a column like this:
Index = RANKX(ALL('Table20'),[NetTotal])- gtamir7 years ago
Post Patron
Yep it works. Thanks
- Greg_Deckler7 years ago
Community Champion
Hooray!
- gtamir6 years ago
Post Patron
Greg_Deckler Greg, just now I noticed that RANKX ranks the same value as the same rank. I need something like row number.
- Greg_Deckler6 years ago
Community Champion
gtamir - Oh, then you want my SuperRank column formula, which I just invented:
SuperRank = VAR __table = FILTER(ALL('Table6'),[Total] > EARLIER('Table6'[Total])) VAR __tableSame = FILTER(ALL('Table6'),[Total] = EARLIER('Table6'[Total]) && [Customer] < EARLIER(Table6[Customer])) RETURN COUNTROWS(__table) + 1 + COUNTROWS(__tableSame)Attaching PBIX, you want Table6.
- Anonymous7 years agoNot applicable
Apart from having an index part of the model or using RANK function (aligning it with the fact your net total is sorted) I am drawing a blank. Greg Deckler may have other suggestions. There is an idea that may be of benefit to you that you may want to upvote
https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/19331770-row-number