Forum Discussion
ChrisAtMAF
5 years agoFrequent Visitor
Converting XML.Tables into usable expandable columns
Hey, I've got some XML with computer data inside it created along similar lines to this article: Creating Custom XML from .NET and PowerShell Hardware: https://pastebin.com/ca1rxYuu Network...
lbendlin
5 years agoSuper User
Something like this?
let
Source = Xml.Tables(File.Contents("C:\Users\xxx\Downloads\computer.xml")),
Object = Source{0}[Object],
#"Expanded Property" = Table.ExpandTableColumn(Object, "Property", {"Element:Text", "Attribute:Name"}, {"Element:Text", "Attribute:Name.1"}),
#"Added Custom" = Table.AddColumn(#"Expanded Property", "Attribute", each [#"Attribute:Name"] & ":" & [#"Attribute:Name.1"]),
#"Reordered Columns" = Table.ReorderColumns(#"Added Custom",{"Attribute", "Element:Text", "Attribute:Name.1", "Attribute:Name"}),
#"Renamed Columns" = Table.RenameColumns(#"Reordered Columns",{{"Element:Text", "Value"}}),
#"Removed Other Columns" = Table.SelectColumns(#"Renamed Columns",{"Attribute", "Value"})
in
#"Removed Other Columns"ChrisAtMAF
5 years agoFrequent Visitor
Hey lbendlin ,
Thanks so much. Sorry, I should have been clearer what I've got.
I've got one of these XML documents for a number of computers in a Power Query column.
Your query looks great but I need the attribute names as columns, not rows, and with lots of them.
In other words, instead of:
I need something more like this:
Happy to provide my existing (messy) code if that would help explain better.
Kind regards,
Chris