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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
PowerBITestingG
Resolver I
Resolver I

Fact table primary key as text or number

So my primary key in my fact table is actually a number, but users want it to be padded with leading zeros. I understand that labeling that as text increases the size by a lot. Would it be better to make that field a number and then create a new column where its padded or is that redundant?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @PowerBITestingG,

In fact, this should relate to your table data amounts. Adding an additional column will affect the performance. You can simply use the 'Text.Length' and 'Text.Repeat' functions to add zero before the string.

Column =
        Table.AddColumn(
            #"Previous Step",
            "columnName",
            each
                Text.Repeat("0", 8 - Text.Length([ID]))
                & Text.From([ID])
        )

Text.Repeat - PowerQuery M | Microsoft Docs

Regards,

Xiaoxin Sheng

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @PowerBITestingG,

In fact, this should relate to your table data amounts. Adding an additional column will affect the performance. You can simply use the 'Text.Length' and 'Text.Repeat' functions to add zero before the string.

Column =
        Table.AddColumn(
            #"Previous Step",
            "columnName",
            each
                Text.Repeat("0", 8 - Text.Length([ID]))
                & Text.From([ID])
        )

Text.Repeat - PowerQuery M | Microsoft Docs

Regards,

Xiaoxin Sheng

jdbuchanan71
Super User
Super User

@PowerBITestingG  That would be redundant and would increase the size more than just converting the primary field to text and adding the leading 0's.  

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.