Forum Discussion

raymondwkmok's avatar
raymondwkmok
Frequent Visitor
1 year ago
Solved

How to use Text.Format for setting a single digit number to doble digit format

Hi there, I'd like to set the numbers in a cloumn to fixed 2-digit format and used the following formula in Power Query but got an error. #"Set 2 Digit" = Table.TransformColumns(#"Changed Type4...
  • OwenAuger's avatar
    1 year ago

    Hi raymondwkmok 

    Number.ToText is the appropriate function if you want to convert a number to a 2-digit text representation.

     

    I would suggest changing the code for this step to:

    #"Set 2 Digit" = Table.TransformColumns(#"Changed Type4",{"Leak Sensor", each Number.ToText(_, "00"), type text})

    Does this work for you?

  • shafiz_p's avatar
    1 year ago

    Hi raymondwkmok  You could also try Text.PadStart , Text.From. Try this:

    =Table.TransformColumns(#"Changed Type", {{"Leak Sensor", each Text.PadStart(Text.From(_), 2, "0"), type text}})
    

     

    Hope this helps!!