Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I am trying to sort Version numbers that will be displayed on a graph and I am running into the infamous sorting where 2.0.10.0 does not come after 2.0.9.0 because it looks at 1 vs 9 (See Below) I cannot convert to numeric because of the number of decimals. Anyone have any suggestions? I have thought of creating a new column and parsing through to 3rd set and pad with 0 for values with a len of 1 for sorting purposes, but making that happen has been tougher than my beginner skills have conquered. I originally made a static table with versions and sort value but that had to be edited manually with each version change making it a pain for reporting. Need something dynamic.
Solved! Go to Solution.
Hi @pchilton,
Do the following steps on advance query editor:
Text.PadStart ([Valid.1], 2, "0") & "." & Text.PadStart ([Valid.2], 2, "0") & "." & Text.PadStart ([Valid.3], 2, "0") & "." & Text.PadStart ([Valid.4], 2, "0")
See below the M Code for a Query editor so you can replicate and look at what I did.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtIz0DM00DNQitWBcIz1DA2ROEZGcI4JkioTPWM42xIkHgsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Version = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Version", type text}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Valid", each [Version]), #"Split Column by Delimiter" = Table.SplitColumn(#"Added Custom", "Valid", Splitter.SplitTextByDelimiter(".", QuoteStyle.Csv), {"Valid.1", "Valid.2", "Valid.3", "Valid.4"}), #"Added Custom1" = Table.AddColumn(#"Split Column by Delimiter", "Sort_Version", each Text.PadStart ([Valid.1], 2, "0") & "." & Text.PadStart ([Valid.2], 2, "0") & "." & Text.PadStart ([Valid.3], 2, "0") & "." & Text.PadStart ([Valid.4], 2, "0")), #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Valid.1", "Valid.2", "Valid.3", "Valid.4"}), #"Sorted Rows" = Table.Sort(#"Removed Columns",{{"Sort_Version", Order.Ascending}}) in #"Sorted Rows"
I assumed that you only go to 2 numbers in each part of the Version that why the Padding of the text for all columns is 2.
Regards,
MFelix
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @pchilton,
On the desktop choose the original column Version and the:
In this option select the new Version column to sort the first one by this new one as you can see below the values are sort by default by the sort column.
Regards,
MFelix
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsCovering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
99 | |
83 | |
70 | |
61 |
User | Count |
---|---|
149 | |
114 | |
107 | |
89 | |
67 |