Forum Discussion
Sorting Summarized table
lbendlin then it should look at the date in End and if both are the same then just sort alphabetically
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCi4pSk0tUXBU0lEyMNQ1sNQ1MgYxLaDMWB1UJUYIJWaYSpxA4qZwJYZG2JUYIkwxwmKRM0iJCcIULBaBlBgYI9xigqnEBVkcyVloSgwRnjbE4hZXoLgCGMfGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Street = _t, Begin = _t, End = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Street", type text}, {"Begin", type date}, {"End", type date}},"nl"),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Street"}, {{"Begin", each List.Min([Begin]), type nullable text}, {"End", each List.Max([End]), type nullable text}}),
#"Sorted Rows" = Table.Sort(#"Grouped Rows",{{"Begin", Order.Ascending}, {"End", Order.Ascending}, {"Street", Order.Ascending}}),
#"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "SortOrder", 1, 1, Int64.Type)
in
#"Added Index"
How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".
Note: you haven't indicated how to sort nulls. Solved: Sort text by ascending and make nulls last - Microsoft Fabric Community
- lbendlin2 years agoSuper User
yes the query will appear as a new table in Power BI, and you can add its columns to a visual as needed.
- lbendlin2 years agoSuper User
Change the Source bit to point to your own source table.
- lbendlin2 years agoSuper User
let
Source=#"New Summarized Table",
...
- lbendlin2 years agoSuper User
Something like this
let Source = #"New Summarized Table", #"Changed Type" = Table.TransformColumnTypes(Source,{{"Adres straat", type text}, {"Begin", type date}, {"Eind", type date}},"nl"), #"Grouped Rows" = Table.Group(#"Changed Type", {"Adres straat"}, {{"Begin", each List.Min([Begin]), type nullable text}, {"Eind", each List.Max([End]), type nullable text}}), #"Sorted Rows" = Table.Sort(#"Grouped Rows",{{"Begin", Order.Ascending}, {"Eind", Order.Ascending}, {"Adres straat", Order.Ascending}}), #"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "SortOrder", 1, 1, Int64.Type) in #"Added Index" - RonaldvdH2 years agoPost Patron
lbendlin yes and no because it does appear as a table but it's not linked to the right source. It's linked to your testfile i'm guessing.
The table in my rapport it has to link with is the table Straten, so how do I do that ?
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCi4pSk0tUXBU0lEyMNQ1sNQ1MgYxLaDMWB1UJUYIJWaYSpxA4qZwJYZG2JUYIkwxwmKRM0iJCcIULBaBlBgYI9xigqnEBVkcyVloSgwRnjbE4hZXoLgCGMfGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Street = _t, Begin = _t, End = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Adres straat", type text}, {"Begin", type date}, {"Eind", type date}},"nl"), #"Grouped Rows" = Table.Group(#"Changed Type", {"Adres straat"}, {{"Begin", each List.Min([Begin]), type nullable text}, {"Eind", each List.Max([End]), type nullable text}}), #"Sorted Rows" = Table.Sort(#"Grouped Rows",{{"Begin", Order.Ascending}, {"Eind", Order.Ascending}, {"Adres straat", Order.Ascending}}), #"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "SortOrder", 1, 1, Int64.Type) in #"Added Index"I've changed the column names to the exact column names in my rapport but the source has to be altered to my table Straten
- RonaldvdH2 years agoPost Patron
lbendlin I wish it were that simple to me but i'm still not getting which part I need to change so can you hold my hand
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCi4pSk0tUXBU0lEyMNQ1sNQ1MgYxLaDMWB1UJUYIJWaYSpxA4qZwJYZG2JUYIkwxwmKRM0iJCcIULBaBlBgYI9xigqnEBVkcyVloSgwRnjbE4hZXoLgCGMfGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Street = _t, Begin = _t, End = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Adres straat", type text}, {"Begin", type date}, {"Eind", type date}},"nl"), #"Grouped Rows" = Table.Group(#"Changed Type", {"Adres straat"}, {{"Begin", each List.Min([Begin]), type nullable text}, {"Eind", each List.Max([End]), type nullable text}}), #"Sorted Rows" = Table.Sort(#"Grouped Rows",{{"Begin", Order.Ascending}, {"Eind", Order.Ascending}, {"Adres straat", Order.Ascending}}), #"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "SortOrder", 1, 1, Int64.Type) in #"Added Index"Which part do I need to remove and where do I reference the summarized table Streets
In het Advancend editor I can only see the original tabel and this query and NOT the summarized table obviously but If you could explain it to my if I was a 5 year old it would help