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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
AmudhaKumaran
Helper I
Helper I

Power Query - Data type

Hi,

I have a text column with a mix of both decimal and alphanumeric values. While importing, leading zeroes are truncated from decimal values. I need to pad only the decimal values to specific length but leave the alphanumeric values unchanged. Tried Text.Padstart but it's changing for all values in that column. Data is as below. 

AmudhaKumaran_0-1684229160968.png

Expected sample output: 
Values starting with G - unchanged
G.025 -> G.025
6.010 -> 06.010
Any quick help is appreciated.

2 ACCEPTED SOLUTIONS
AlienSx
Super User
Super User

Hi, @AmudhaKumaran 

Table.TransformColumns(your_table, {"Code", (x) => if (try Number.From(x))[HasError] then x else Text.PadStart(x, 6, "0"})

View solution in original post

m_dekorte
Resident Rockstar
Resident Rockstar

Hi @AmudhaKumaran 

 

You could use a replace value step 

m_dekorte_0-1684230667849.png

 

Copy this into a new blank query

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WctczMDJQitVBZ5mSxDLTMzA0gLMMMVkGcHUGFkqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Code = _t]),
    ReplValue = Table.ReplaceValue( Source, each [Code], each if (try Number.From([Code]))[HasError] then [Code] else Text.PadStart( Text.From( [Code] ), 6, "0"), Replacer.ReplaceText, {"Code"} )
in
    ReplValue

 

Ps. If this helps solve your query please mark this post as Solution, thanks!

View solution in original post

4 REPLIES 4
m_dekorte
Resident Rockstar
Resident Rockstar

Hi @AmudhaKumaran 

 

You could use a replace value step 

m_dekorte_0-1684230667849.png

 

Copy this into a new blank query

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WctczMDJQitVBZ5mSxDLTMzA0gLMMMVkGcHUGFkqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Code = _t]),
    ReplValue = Table.ReplaceValue( Source, each [Code], each if (try Number.From([Code]))[HasError] then [Code] else Text.PadStart( Text.From( [Code] ), 6, "0"), Replacer.ReplaceText, {"Code"} )
in
    ReplValue

 

Ps. If this helps solve your query please mark this post as Solution, thanks!

Thanks for your help @m_dekorte . It works fine.

AlienSx
Super User
Super User

Hi, @AmudhaKumaran 

Table.TransformColumns(your_table, {"Code", (x) => if (try Number.From(x))[HasError] then x else Text.PadStart(x, 6, "0"})

Thanks @AlienSx for your swift response. Solution works great.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.