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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
AlexHeinze
Frequent Visitor

XML input - how to handle missing tables

I have an XML file that contains multiple tables. Unfortunately the external system excludes tables (and columns) from the XML if they have no data, so this breaks my import in Power Query:

 

let Source = Xml.Tables(File.Contents(SavedXML)), works fine
Optional_Table = Source{[Name="Optional_Table"]}[Table], breaks

 

I'm using Table.SelectColumns with MissingField.UseNull to handle missing columns, but haven't found a way to do something similar if the entire table is missing.

 

What should happen is that the the table gets created in Power Query, but without any row (or a dummy row if needed). Is that achievable?

1 ACCEPTED SOLUTION

I think I found a solution. I created a dummy query that holds the optional XML elements. I then appended the dummy query....

 

let
Source = Xml.Tables(File.Contents(SavedXML)),
#"Appended Query" = Table.Combine({Source, Dummy_XML}),

 

...which worked if the XML was missing. If the XML already had the element, I ended up with a duplicate row that I removed using


#"Removed Duplicates" = Table.Distinct(#"Appended Query",{"Name"}),

 

Seems to do the job.

View solution in original post

2 REPLIES 2
v-kkf-msft
Community Support
Community Support

Hi @AlexHeinze ,

 

Are you importing an empty table as shown below? 

 

vkkfmsft_0-1663032158844.png

 

Perhaps you can select the "Source" step in the already imported table and then you will be able to see the empty table.

 

vkkfmsft_1-1663032333013.png

 

Best Regards,
Winniz

 

I think I found a solution. I created a dummy query that holds the optional XML elements. I then appended the dummy query....

 

let
Source = Xml.Tables(File.Contents(SavedXML)),
#"Appended Query" = Table.Combine({Source, Dummy_XML}),

 

...which worked if the XML was missing. If the XML already had the element, I ended up with a duplicate row that I removed using


#"Removed Duplicates" = Table.Distinct(#"Appended Query",{"Name"}),

 

Seems to do the job.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.

Top Kudoed Authors