Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

XML Source - Getting child value with XQuery

Hi, I have an XML file as a source, I can easily get every row's elements values and simple agregates for direct decendents of the rows. I would like to bring some values from further down into the ...
  • rajendraongole1's avatar
    1 year ago

    Hi Anonymous - To retrieve the first value of "Field A" from your XML structure and bring it to the top level for each row, you can use Power Query's native XML handling capabilities, which unfortunately don't directly support XQuery. 

    alternatively, you can still achieve this by parsing the XML structure using functions like Xml.Tables, Table.ExpandTableColumn, and Table.TransformColumns.

    In Power Query, you can load the XML file directly from a source, such as a file, or copy-paste it into the query editor.Use Xml.Tables to Convert XML to a Table: Power Query has a function called Xml.Tables that can parse the XML into a structured table.Navigate Through the Nested Tables: Once the XML is parsed, you'll need to drill down through the hierarchy to get the value of customfieldvalue for Field A. You can use Table.ExpandTableColumn to flatten the nested columns and bring the custom field value to the top level.

    reference code attached FYI