'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.



Solution 1:[1]

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

where Col is the column name.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user4979733