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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
mertzdj
New Member

How to prevent empty values from loading as tables instead of nulls when load is an xml file

I'm loading similar query with multiple inputs as Xml.Tables(Web.Contents(...

 

When I drill down, often times empty xml tags come in as "Table" instead of as null values or empty string.  How can I blanket load and do expands that generate as nulls instead of empty tables.  

 

When they return to Excel they show up as text "Table".

2 REPLIES 2
amirshiloh
Advocate I
Advocate I

i have added the following lines at the end of my Power Query:
#"ReplaceEmptyTables"= Table.TransformColumnTypes(#"Sorted Rows",{{"SampleColumn1", type text},{"SampleColumn2", type text},{"SampleColumn3", type text}}),
#"Replaced Errors" = Table.ReplaceErrorValues(ReplaceEmptyTables, {{"SampleColumn1", ""}, {"SampleColumn2", ""},{"SampleColumn3", ""}})

v-stephen-msft
Community Support
Community Support

Hi @mertzdj ,

 

To replace empty XML tags with null values or empty strings, you can use the Xml.Tables function in combination with the Table.ReplaceValue function.

let
    Source = Xml.Tables(Web.Contents("https://example.com")),
    ReplaceEmptyTables = Table.ReplaceValue(Source, {}, null, Replacer.ReplaceValue, {"Column1", "Column2", "Column3"})
in
    ReplaceEmptyTables

In this example, we first load the XML data using the Xml.Tables function. Then, we use the Table.ReplaceValue function to replace any empty tables in the specified columns with null values. The Replacer.ReplaceValue option tells the function to replace the empty tables with the specified value, which in this case is null. You can also replace empty tables with an empty string by replacing null with "".

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.           

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors