Forum Discussion
Looping through rows to find the largest link
- 3 years ago
Hi Anonymous ,
According to your description, here's my solution.
1. Create a custom column.
Length = Text.Length([Link])2. Create another custom column.
Output = let T=Table.SelectRows(#"Added Custom1",(x)=>Text.Start(x[Link],1)=Text.Start([Link],1)) in Table.SelectRows(#"Added Custom1",(x)=>Text.Start(x[Link],1)=Text.Start([Link],1)and x[Length]=List.Max(T[Length]))[Link]{0}Get the correct result:
Here's the whole M syntax:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUXIC4oAgfxcg5eikFKsDEXVGEnUGi4JEXJDVOruAxZ3QVDs5ww0JRRIOBYuCmJ6ohnjCTYEgqCPC4AJhWPnOSBqc4WbDRSBuC0UIQez3RFGDzepYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Parent = _t, Child = _t, Param = _t, Link = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Parent", type text}, {"Child", type text}, {"Param", type text}, {"Link", type text}}), #"Added Custom1" = Table.AddColumn(#"Changed Type", "Length", each Text.Length([Link])), #"Added Custom" = Table.AddColumn(#"Added Custom1", "Output", each let T=Table.SelectRows(#"Added Custom1",(x)=>Text.Start(x[Link],1)=Text.Start([Link],1)) in Table.SelectRows(#"Added Custom1",(x)=>Text.Start(x[Link],1)=Text.Start([Link],1)and x[Length]=List.Max(T[Length]))[Link]{0}), #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Length"}) in #"Removed Columns"I attach my sample below for your reference.
Best Regards,
Community Support Team _ kalyjIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Anonymous ,
According to your description, here's my solution.
1. Create a custom column.
Length = Text.Length([Link])
2. Create another custom column.
Output = let
T=Table.SelectRows(#"Added Custom1",(x)=>Text.Start(x[Link],1)=Text.Start([Link],1))
in
Table.SelectRows(#"Added Custom1",(x)=>Text.Start(x[Link],1)=Text.Start([Link],1)and x[Length]=List.Max(T[Length]))[Link]{0}
Get the correct result:
Here's the whole M syntax:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUXIC4oAgfxcg5eikFKsDEXVGEnUGi4JEXJDVOruAxZ3QVDs5ww0JRRIOBYuCmJ6ohnjCTYEgqCPC4AJhWPnOSBqc4WbDRSBuC0UIQez3RFGDzepYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Parent = _t, Child = _t, Param = _t, Link = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Parent", type text}, {"Child", type text}, {"Param", type text}, {"Link", type text}}),
#"Added Custom1" = Table.AddColumn(#"Changed Type", "Length", each Text.Length([Link])),
#"Added Custom" = Table.AddColumn(#"Added Custom1", "Output", each let T=Table.SelectRows(#"Added Custom1",(x)=>Text.Start(x[Link],1)=Text.Start([Link],1))
in
Table.SelectRows(#"Added Custom1",(x)=>Text.Start(x[Link],1)=Text.Start([Link],1)and x[Length]=List.Max(T[Length]))[Link]{0}),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Length"})
in
#"Removed Columns"
I attach my sample below for your reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous3 years agoNot applicable
It works ! thank you