Forum Discussion
JustDavid
1 year agoHelper IV
Insert text to a list dynamically from another list/table
I'd like to 2 things to my existing list.
- Modify text in list
- Append existing list Nth times depending on the values that's coming from another table/list (currently print screen showing as table)
From the print screen below, I'm showing you the table/list and end result
Tried a different method that can achive my end result via merging, however, it's very slow
String to AddCurrent List Desired Result
let string_to_add = #table({"Data"}, {{"A"}, {"B"}, {"C"}}), list_to_add = List.Buffer(string_to_add[Data]), current_list = {"text | text | text", "sometext | sometext | sometext", "string | sometext | anothertext"}, addition = List.TransformMany( current_list, (x) => list_to_add, (x, y) => y & " | " & x ) in addition
3 Replies
- jgeddesSuper User
Here is one way it can be done...
let tableSource = #table( {"Data"}, { {"A"}, {"B"}, {"C"} } ), listSource = { "text | text | text", "sometext | sometext | sometext", "string | sometext | anothertext" }, table_to_list = Table.ToList(table), table_row_count = List.Count(table_to_list), modified_list = List.Transform( List.Zip( { List.Repeat(table_to_list, table_row_count), List.Repeat(list, table_row_count) } ), each Text.Combine(_, " | ") ) in modified_list - AlienSxSuper User
let string_to_add = #table({"Data"}, {{"A"}, {"B"}, {"C"}}), list_to_add = List.Buffer(string_to_add[Data]), current_list = {"text | text | text", "sometext | sometext | sometext", "string | sometext | anothertext"}, addition = List.TransformMany( current_list, (x) => list_to_add, (x, y) => y & " | " & x ) in addition