PowerBI: How to assign unique values to a Column containing text data

Viewed 96

Say I have a column with Text data like:

A
B
A
D

I would like to create a new column so that the end result is:

A 0
B 1
A 0 
D 2

What is the correct way do this is PowerBI Power Query Editor? I tried a few things like indexing but that gives a unique value to every row. Not very familiar with the API so am a bit stuck here.

1 Answers

We can do something like: List.PositionOf(List.Distinct(Table.Column( #"Table name", "Col")), [Col]))

where Col is the column name.

Related