Forum Discussion
Anonymous
3 years agoNot applicable
Adding a simple index column using dax
Hi,
I just want to add an index column to a calculated table in Power BI. Every solution that I have seen uses RANKX to compare rows & assign a rank to them. But, in my case I have duplicate rows too & I do not care about their rank. I just need a unique serial number column which I can use for cumulative sum.
The input table looks something like this. I need to add a Sr no. column without considering any rank or logic.
| Product | Move-Type | Pieces | Sr no. |
| 4343 | MM | 2 | 1 |
| 3243 | Flex | 5 | 2 |
| 54543 | NM | 2 | 3 |
| 2431 | fLEX | 2 | 4 |
Thanks in advance for your help
Regards,
Samyak
So if I understand you correctly, the rows marked "Must Move" should be ranked as more important (i.e. lower index) than "Flexible", with "Not Move" being less important.
If you have this Column already:
Foo = "Foo"And this column:MyPriority = IF ( [Move priority] = "Must Move", 1, IF ( [Move priority] = "Flexible", 2, 3))Then you can add this column:My Rank = RANK(DENSE,,ORDERBY('Table'[MyPriority], ASC, 'Table'[MATNR], ASC),DEFAULT,PARTITIONBY('Table'[Foo]),)Result: