I'm looking to understand how to filldown (or up) a column with a if condition, using PowerQuery or pandas (or SQL ?). As you can see i have a "string_values" with null values. When the instance are the same (same number), i want to fill the string values.
Thanks for your help !
CodePudding user response:
In powerquery, (assuming there is only ever one row where instance has a value filled in for string_value)
use the drop down atop the column to filter string_value to remove nulls
Start with the data before you changed anything and merge this into it. Use left outer join, and match the instance column against each other
Expand and remove extra column
sample code:
let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Filtered Rows" = Table.SelectRows(Source, each ([string_value] <> null)),
#"Merged Queries" = Table.NestedJoin(Source,{"instance"},#"Filtered Rows",{"instance"},"Filtered Rows",JoinKind.LeftOuter),
#"Expanded Filtered Rows" = Table.ExpandTableColumn(#"Merged Queries", "Filtered Rows", {"string_value"}, {"string_value.new"})
in #"Expanded Filtered Rows"