Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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 find any value when it promoted the headers.
What can I do to make the upload continue smoothly when a table is empty?
I would like, by identifying the table to be empty, Power BI or ignore this table, or write only the headers that I need to continue the script.
Something like:
if (Table.IsEmpty = true) then Table.FromRows ({ {null, null}}, {field1, field2}) else each ([field1] <> "xxxxx"))
I'm using a translator, sorry.
Thank you so much!
-----------------------------------------
Estou carregando 20 tabelas diretamente para o powerbi. Esse carregamento será mensal, porém pode acontecer de uma tabela ou outra estar vazia.
Por isso, quando faço a alteração do tipo do campo, o script é interrompido, porque o Power BI não encontrou nenhum valor quando promoveu os cabeçalhos.
O que posso fazer para que o carregamento continue sem problemas quando uma tabela estiver vazia?
Gostaria de, ao identificar que a tabela é vazia, o Power BI ou ignorasse esta tabela, ou escrevesse apenas os cabeçalhos que preciso para dar continuidade no script.
Algo como:
if (Table.IsEmpty = true) then Table.FromRows({{null, null}},{campo1, campo2}) else each ([campo1] <> "xxxxx"))Muito Obrigado!
Are these 20 tables being loaded in 20 different queries?
Yes
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"
I will try it, thank you so much!
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 63 | |
| 55 | |
| 42 | |
| 41 | |
| 23 |
| User | Count |
|---|---|
| 166 | |
| 135 | |
| 120 | |
| 79 | |
| 53 |