Forum Discussion
Combine text ( without duplicating) based on another column
- 3 years ago
Thank you ThxAlot . I was able to get the output however, is it possible to have them sorted to be in ascending order For example: I am getting values like 2022,2020,2021 is there a way where I can get it in ascending order like 2020,2021,2022 other than by sorting the table by year?
Thanks,AnthonyJoseph
- Anonymous3 years ago
Hi AnthonyJoseph ,
Make a little change to ThxAlot's code:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTIyMDICUoYGBkqxOnAhCIUhZIwqZACkTKBCRgizTFFEQGrNgCKxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Client = _t, Year = _t, Revenue = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Client", Int64.Type}, {"Year", Int64.Type}, {"Revenue", Int64.Type}}), Grouped = Table.Group(Source, "Client", {"grp", each Table.AddColumn(_, "Yrs in scope", (r) => Text.Combine(List.Sort(List.Distinct([Year])),","))}), Table = Table.Combine(Grouped[grp]) in TableBest Regards,
Gao
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Thank you ThxAlot . I was able to get the output however, is it possible to have them sorted to be in ascending order For example: I am getting values like 2022,2020,2021 is there a way where I can get it in ascending order like 2020,2021,2022 other than by sorting the table by year?
Thanks,
AnthonyJoseph
Hi AnthonyJoseph ,
Make a little change to ThxAlot's code:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTIyMDICUoYGBkqxOnAhCIUhZIwqZACkTKBCRgizTFFEQGrNgCKxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Client = _t, Year = _t, Revenue = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Client", Int64.Type}, {"Year", Int64.Type}, {"Revenue", Int64.Type}}),
Grouped = Table.Group(Source, "Client", {"grp", each Table.AddColumn(_, "Yrs in scope", (r) => Text.Combine(List.Sort(List.Distinct([Year])),","))}),
Table = Table.Combine(Grouped[grp])
in
Table
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum