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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.