cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Prodigy
Post Prodigy

Adding a prefix to data to achieve character length of "5" numeric digits

I am working with a dataset that has a column whose data is between 1 and 5 digits, representing an ID.  For the purpose of my process I need to ensure that he output through Power BI is always 5 digits in lenght.

 

Is there a way that I can add zeroes to the number in this column to create a 5 digit numeric field - ALWAYS.  

 

For instance:

 

Original: 8

Desired:  00008

 

Original: 42

Desired:  00042

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Anonymous
Not applicable

Re: Adding a prefix to data to achieve character length of "5" numeric digits

You can use Format DAX function :-

 

Create a calculated column, something like below :-

 

NEW_ID = FORMAT(Table1[ID],"00000")

 

Only drawback is that this new column will be of string type.

Integer won't take zeroes before numeral.

View solution in original post

6 REPLIES 6
Highlighted
Anonymous
Not applicable

Re: Adding a prefix to data to achieve character length of "5" numeric digits

You can use Format DAX function :-

 

Create a calculated column, something like below :-

 

NEW_ID = FORMAT(Table1[ID],"00000")

 

Only drawback is that this new column will be of string type.

Integer won't take zeroes before numeral.

View solution in original post

Highlighted
Super User IV
Super User IV

Re: Adding a prefix to data to achieve character length of "5" numeric digits

Column = FORMAT([Column1],"00000")

---------------------------------------

Putting square pegs in round holes since 1972.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Highlighted
Post Prodigy
Post Prodigy

Re: Adding a prefix to data to achieve character length of "5" numeric digits

@Greg_Deckler

 

Thanks os much.  Should this column grow over time, is there a condition which I can create that would make this columns a min of 5 digits by adding zeroes, but honor values of greater than 5 digits.

 

Thoughts?

Highlighted
Super User IV
Super User IV

Re: Adding a prefix to data to achieve character length of "5" numeric digits

That formula will actually already do that.


---------------------------------------

Putting square pegs in round holes since 1972.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Highlighted
Post Prodigy
Post Prodigy

Re: Adding a prefix to data to achieve character length of "5" numeric digits

@Greg_Deckler

 

Thank you sir.

Highlighted
Advocate I
Advocate I

Re: Adding a prefix to data to achieve character length of "5" numeric digits

In M language on Power Query Editor you can use:

= Table.TransformColumns(#"previous step", {{"ID", each Text.PadStart(Text.From(_),5,"0"), type text}})

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors