user4979733
user4979733

Reputation: 3411

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

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.

Upvotes: 1

Views: 545

Answers (1)

user4979733
user4979733

Reputation: 3411

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

where Col is the column name.

Upvotes: 1

Related Questions