Forum Discussion
mertzdj
3 years agoNew 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 ...
Anonymous
3 years agoNot applicable
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.