Forum Discussion
fabiodm7
8 years agoNew Member
Ignore empty table on load
I'm loading 20 tables directly into the powerbi. This upload will be monthly, but a table or another table may be empty. So when I change the field type, the script stops because Power BI did not fi...
Greg_Deckler
8 years agoCommunity Champion
Are these 20 tables being loaded in 20 different queries?
MarcelBeug
8 years agoCommunity Champion
The code below creates a table, at random either empty or with 2 columns and 2 rows (1 header and 1 data).
Next, if the table is empty, it creates a table with 2 columns and 1 row (for the headers).
Then the headers are promoted.
let
Source = if Number.Random() < 0.5 then #table(0,{}) else #table(2,{{"field1","field2"},{"value1","value2"}}),
Custom1 = if Table.IsEmpty(Source) then #table(2,{{"field1","field2"}}) else Source,
#"Promoted Headers" = Table.PromoteHeaders(Custom1, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"field1", type text}, {"field2", type text}})
in
#"Changed Type"- fabiodm78 years agoNew Member
I will try it, thank you so much!