Forum Discussion

Lewdis_'s avatar
Lewdis_
Frequent Visitor
1 year ago
Solved

Create ID from values in column

I have a dataset with product category as one column in the product dataset. Since i have a lot of products this column is for each of them.    Is there a simple way to give them and ID number from...
  • MNedix's avatar
    1 year ago

    Heya,

    For this kind of data (e.g. Products) it is adviceable to have a dedicated table with unique values so you can easily manage relationships and other calculations. If you don't already have one, then you can create a Products table using the code below (assuming that 'Table' is your dataset table):

    Products = DISTINCT(SELECTCOLUMNS('Table',"Products",'Table'[Category))

     

    Then, you can simply add a calculated index column with the code:

    Index = RANKX(ALL('Products'),'Products'[Products],,ASC)

     Hope it helps.