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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PowerBITestingG
Advocate II
Advocate II

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
v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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