Forum Discussion
Dicken
1 year agoPost Prodigy
Make records consistent ;
Hi, when working with liists I often end up with lists fo records and wnat to make the them same size, example ; { [ A = 1, C = 2 , D = 3] , [ C = 2, A = 1, E = 3] , [C = 4, E...
- 1 year ago
If you just want to complete the field name, you can use the following code:
let Source = { [ A = 1, C = 2 , D = 3] , [ C = 2, A = 1, E = 3] , [C = 4, E = 5] }, result = List.Transform( Source, each [A = null, B = null, C = null, D = null, E = null] & _ ) in resultIf you want to convert the records into a table and complete all the columns, you can use the following code:
let Source = { [ A = 1, C = 2 , D = 3] , [ C = 2, A = 1, E = 3] , [C = 4, E = 5] }, result = Table.FromRecords( Source, type table [A = nullable text, B = nullable text, C = nullable text, D = nullable text, E = nullable text], MissingField.UseNull ) in result
Vijay_A_Verma
1 year agoMost Valuable Professional
Insert this as your next step
= List.Transform(recs, (x)=> Record.Combine({Record.FromList(List.Repeat({null}, 5), {"A".."E"}), x}))
Hence, your code would become
let
recs = { [ A = 1, C = 2 , D = 3] ,
[ C = 2, A = 1, E = 3] ,
[C = 4, E = 5]}
in
List.Transform(recs, (x)=> Record.Combine({Record.FromList(List.Repeat({null}, 5), {"A".."E"}), x}))
Dicken
1 year agoPost Prodigy
This has nothing to to do with the question but the above interface,
If I want to show code, what is the recomeneded method, should I just add it and then put tags <>
around?