Forum Discussion
Extract Values From a List of Records
- 4 years ago
Hi FlyKick
I think I made it!
Add a custom column with below code:
let typeList = [types], typeCount = List.Count([types]) in Text.Combine(List.Transform(List.Numbers(0, typeCount, 1), each Record.Field(typeList{_},"Name")), ", ")Attached the complete M code for your reference.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXJycgKSlgZKsTrRSkZAppeXF5A0twQLGAOZjo5AwsQMzDcBMr29vYGkkYVSbCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Id = _t, Name = _t, Value = _t]), SourceToList = {Table.ToRecords(Source),Table.ToRecords(Table.RemoveFirstN(Source,1)),{}}, #"Converted to Table" = Table.FromList(SourceToList, Splitter.SplitByNothing(), null, null, ExtraValues.Error), #"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "types"}}), #"Added Custom1" = Table.AddColumn(#"Renamed Columns", "Custom", each let typeList = [types], typeCount = List.Count([types]) in Text.Combine(List.Transform(List.Numbers(0, typeCount, 1), each Record.Field(typeList{_},"Name")), ", ")) in #"Added Custom1"Let me know if you have any questions.
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
Hello,
I have a similar challange I'm trying to solve for as the OP. The code provided in this thread worked really well to pull and combine a string of text values from the each "Record" within the "List".
= Table.AddColumn(#"Changed Type1", "Custom", each let typeList = [Workers], typeCount = List.Count([Workers]) in Text.Combine(List.Transform(List.Numbers(0, typeCount, 1), each Record.Field(typeList{_},"WorkerName")), ", "))
However, I need to dig into one more record layer. I need to get into the record on "WorkerName" and pull the values for "First" and "Last".
Right now, the results are giving me an error because "Record" in WorkerName is not a text value. I imagine I need to nest a portion of the code above into another segment, but I have no idea where to go from here.
Any help would be appriciated!