Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
fabiodm7
New 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 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!

4 REPLIES 4
Greg_Deckler
Community Champion
Community Champion

Are these 20 tables being loaded in 20 different queries?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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"
Specializing in Power Query Formula Language (M)

I will try it, thank you so much!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.