Forum Discussion
onefousanflee
3 years agoRegular Visitor
Fill down first cell after Null/blank
Hello! I'm trying to use Power Query to get data from our non-traditional data source. Here's one problem I'm facing: They updated the data in a different way: and I need to transform data...
- 3 years ago
Step 1. Add Index column
Step 2. Add marker column to find Room names
Step 3. Add new column: Room
Step 4. Fill it down
Step 5. Leave only few columns with filter on marker = false and ColumnValue <> ""
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bZDNCoNADITfZc/bQ3+eQNsiFUUU9CAeggYtTTfFn8L69LVxaS9elpmE+TJsWaqU+bnbq0qXqoC+0TeROUxtB0aH4nwCO7LRsbgzG34vu0Kc13P9cKn/I9SDyISJvmBfXMz0w3pApFORAfMLex25sNXXLeBxRbSTReOCIeHd6IvoCIalZCY6A1N3ODtODoRmnpDArbfop7UU9u3SxFvniAO6SxkQDO5SAiOS+44AbLPUyVVVfQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ColumnValue = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"ColumnValue", type text}}), #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type), #"Added Marker" = Table.AddColumn(#"Added Index", "Marker", each let currentIndex = [Index], currentValue = [ColumnValue], previousValue = List.First(Table.SelectRows(#"Added Index", each [Index] = currentIndex - 1)[ColumnValue]), marker = if (previousValue = "" or previousValue = null) and currentValue <> previousValue then true else false in marker), #"Added Room" = Table.AddColumn(#"Added Marker", "Room", each if [Marker] then [ColumnValue] else null), #"Filled Down Room" = Table.FillDown(#"Added Room",{"Room"}), Result = Table.SelectColumns(Table.SelectRows(#"Filled Down Room",each [Marker] = false and [ColumnValue] <> ""),{"Room","ColumnValue"}) in Result
bolfri
3 years agoSolution Sage
Step 1. Add Index column
Step 2. Add marker column to find Room names
Step 3. Add new column: Room
Step 4. Fill it down
Step 5. Leave only few columns with filter on marker = false and ColumnValue <> ""
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bZDNCoNADITfZc/bQ3+eQNsiFUUU9CAeggYtTTfFn8L69LVxaS9elpmE+TJsWaqU+bnbq0qXqoC+0TeROUxtB0aH4nwCO7LRsbgzG34vu0Kc13P9cKn/I9SDyISJvmBfXMz0w3pApFORAfMLex25sNXXLeBxRbSTReOCIeHd6IvoCIalZCY6A1N3ODtODoRmnpDArbfop7UU9u3SxFvniAO6SxkQDO5SAiOS+44AbLPUyVVVfQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ColumnValue = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ColumnValue", type text}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
#"Added Marker" = Table.AddColumn(#"Added Index", "Marker", each let
currentIndex = [Index], currentValue = [ColumnValue],
previousValue = List.First(Table.SelectRows(#"Added Index", each [Index] = currentIndex - 1)[ColumnValue]),
marker = if (previousValue = "" or previousValue = null) and currentValue <> previousValue then true else false
in marker),
#"Added Room" = Table.AddColumn(#"Added Marker", "Room", each if [Marker] then [ColumnValue] else null),
#"Filled Down Room" = Table.FillDown(#"Added Room",{"Room"}),
Result = Table.SelectColumns(Table.SelectRows(#"Filled Down Room",each [Marker] = false and [ColumnValue] <> ""),{"Room","ColumnValue"})
in
Result
onefousanflee
3 years agoRegular Visitor
Thx again! it works!