0

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.

2
  • What column do you want to sort by? Commented Mar 26, 2019 at 17:36
  • Nothing Specific. Everything like that is done on the Query Editor. But, if you need one - Take ColA Commented Mar 26, 2019 at 17:38

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Excellent solution

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.