March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
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!
Solved! Go to Solution.
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.
The above fix did not work for me. I am in Transform Data. I found the below to help.
Create a custom column equal to below:
= text.padstart([column_name],5,"0")
Column_Name is of course you column, the 5 is how manay total digits you want, and the "0" is where you tell it you want to add 0's to the front.
This function will works only on text string. You should transform the format to type text. You can do this using Text.From as below:
= Text.PadStart(Text.From([column_name]),5,"0")
In M language on Power Query Editor you can use:
= Table.TransformColumns(#"previous step", {{"ID", each Text.PadStart(Text.From(_),5,"0"), type text}})
Got this to work from your Post... Thanks...
Column = FORMAT([Column1],"00000")
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?
That formula will actually already do that.
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.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
127 | |
85 | |
69 | |
53 | |
44 |
User | Count |
---|---|
202 | |
106 | |
100 | |
64 | |
56 |