Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Janaya1
Frequent Visitor

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

 

1 ACCEPTED SOLUTION
techies
Super User
Super User

@Janaya1 please try this calculated column

 

Categorical Value =
VAR CategoryIndex =
    RANKX(
        ALL(Sheet1[Category]),  
        sheet1[Category],      
        , ASC, DENSE              
    )
RETURN CategoryIndex
― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978

View solution in original post

2 REPLIES 2
techies
Super User
Super User

@Janaya1 please try this calculated column

 

Categorical Value =
VAR CategoryIndex =
    RANKX(
        ALL(Sheet1[Category]),  
        sheet1[Category],      
        , ASC, DENSE              
    )
RETURN CategoryIndex
― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978

thank you!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Top Solution Authors