My objective is to insert a "null" row to my dimensions in a dataflow.
Before
key | name | age |
---|---|---|
aaa | John | 20 |
bbb | Doe | 33 |
After
key | name | age |
---|---|---|
aaa | John | 20 |
bbb | Doe | 33 |
-1 | null | null |
I currently do this with:
Table.InsertRows(prevStep, 0, {[
key = "-1",
name = null,
age = null
]}
)
Question
But can I somehow do the same operation, without having to type all the null
columns?
Here you go:
let
Source = Table.FromRecords({
[key="aaa", name="John", age=20],
[key="bbb", name="Doe", age=33]
}),
#"Changed Type" = Table.TransformColumnTypes(Source,
{
{"key", type text},
{"name", type text},
{"age", Int64.Type}
}),
#"Inserted Rows" = Table.InsertRows(#"Changed Type",
Table.RowCount(#"Changed Type"), // insert at table end
{
Record.FromList(
List.Combine({
{"-1"},
List.Repeat(
{null}, Table.ColumnCount(#"Changed Type") - 1)
}),
Table.ColumnNames(#"Changed Type")
)
})
in
#"Inserted Rows"