Skip to content

Instantly share code, notes, and snippets.

@ImkeF
Created March 16, 2021 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ImkeF/187e5c3840738c70276810c4ad2fef4b to your computer and use it in GitHub Desktop.
Save ImkeF/187e5c3840738c70276810c4ad2fef4b to your computer and use it in GitHub Desktop.
(MyTable as table, MyColumnName as text) =>
// Pads a number column with leading zeroes so that an alphabetical sort returns the same than a numerical sort.
// www.TheBIccountant.com
let
Source = Table.TransformColumns(
MyTable,
{
{
MyColumnName,
each Text.PadStart(
Text.From(_),
Text.Length(
Text.From(
List.Max(
Table.Column(
Table.TransformColumns(
MyTable,
{{MyColumnName, Number.From}}
),
MyColumnName
)
)
)
),
"0"
),
type text
}
}
)
in
Source
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment