Forum Discussion

Janaya1's avatar
Janaya1
Frequent Visitor
1 year ago
Solved

Create new numeric column from Categorical column

Is there a way to create a new column from a categorical column that acts like a numerical reference that is unique for that category without creating an if then statement that lists each category or a map? I have hundreds of different categories in a column that need unique numbered categories. I think this shouldn't be difficult but maybe I'm just overthinking it?

 

For example:

 

starting table

CategoryValue
A70
A64
B26
A58
C49
D26
A06
B13
D46
C18

 

resulting table

CategoryValueCategorical Value
A701
A641
B262
A581
C493
D264
A061
B132
D464
C183

 

  • Janaya1 please try this calculated column

     

    Categorical Value =
    VAR CategoryIndex =
        RANKX(
            ALL(Sheet1[Category]),  
            sheet1[Category],      
            , ASC, DENSE              
        )
    RETURN CategoryIndex

2 Replies

  • Janaya1 please try this calculated column

     

    Categorical Value =
    VAR CategoryIndex =
        RANKX(
            ALL(Sheet1[Category]),  
            sheet1[Category],      
            , ASC, DENSE              
        )
    RETURN CategoryIndex