Forum Discussion
Syndicate_Admin
2 years agoAdministrator
Fill empty cell with value contained within the same column but with a condition within another colum
Hello everybody, I'm starting my journey with PowerQuery and I'm currently facing an issue that could be solved with your suuport. I have a table containing various requests (column id). Some...
AlienSx
2 years agoSuper User
Hello, RVIG
one of several options to solve this:
let
Source = your_table,
values = Table.SelectRows(Table.Distinct(Source[[parent_id], [DATA]]), each [DATA] <> null),
dict = Record.FromList(values[DATA], List.Transform(values[parent_id], Text.From)),
helper_column =
Table.AddColumn(
Source, "helper",
(x) =>
if x[DATA] = null
then Record.FieldOrDefault(dict, Text.From(x[parent_id]), null)
else x[DATA]
)
in
helper_columnthen remove "DATA" column and rename "helper" as you want. Instead of exta (temporal) column one may choose to use Table.ReplaceValue (proved to be slower than other options) or a combination of Record.TransformFields and Table.TransformRows functions.