Forum Discussion

Sergei-StPete's avatar
Sergei-StPete
Frequent Visitor
3 months ago
Solved

Number to text with leading zeroes and query folding

Something like Number.ToText( 2, "00") works fine and returns "02" if only we don't keep query folding with SQL server. In such case above returns "2".  Text.PadStart( Number.ToText( 2, "00"), 2, "0"...
  • krishnakanth240's avatar
    3 months ago

    Hi Sergei-StPete 

    To preserve query folding, approach is to push the formatting logic to SQL compatible text operations instead using `Text.PadStart`.

    #powerquery

    RIGHT("00" & Number.ToText([Column]), 2)

    #PowerqueryM

    Text.End("00" & Number.ToText([Column]), 2)