0
votes

I have a table Like this,

Table1

ColA   ColB
Orange Apple
Mango  Not Apple
Mango  Not Apple

I want to create a column called as RowNumber using DAX and not Query Editor (M).

So the Expected output is,

ColA     ColB        RowNumber
Orange   Apple       1
Mango    Not Apple   2
Mango    Not Apple   3

This can be done in M - Power Query Side.

But, I am looking for a solution using DAX- Calculated Column.

I expected functions like RowNumber (T-SQL) or Index to be present inside DAX.

1
What column do you want to sort by?Ryan B.
Nothing Specific. Everything like that is done on the Query Editor. But, if you need one - Take ColASiddharth Thanga Mariappan

1 Answers

3
votes

If you need to create an Index in DAX you can use this formula:

Index = RANKX(ALL(Barges),Barges[Date],,ASC)

RANKX: create your Index values

ALL: to avoid your Index to be partially generated if you have any filter

The second parameter is from where you want to sort your data, in my example I have an Index number increasing with an ascending order on my date, if I use Barges[name] instead for example I'll have my index generating with an A-Z sorting on my barges names.