- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
XML Hierarchical data expanding error in Power Query
Hello!
I am having problems with consuming an XML file that has hierarchical data.
This is the structure of the XML file. I want to read the columns shown in green. Note that "LAST_DAY_UPDATED" has multiple values, therefore, the rows will need to be expanded so that each record contains one of the "LAST_DAY_UPDATED".
Note that the dates are two levels below the "Individual" level
This is the source XML file
https://scsanctions.un.org/resources/xml/en/consolidated.xml
This is the column that needs to be expanded, shown in Power BI Desktop.
When expanded, the field data appears as Tables.
Note that there is no option to further expand "Values" column eventhough cells are shown as "Table"
When clicked on a particular cell, it shows the underlying data, as below
As a result, I am unable to expand the dates.
Any advice on how to fix this error and explanation on why Power Query behaves this way?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Surm, just write another Table.ExpandTableColumn manualy:
Output:
let
Source = Xml.Tables(Web.Contents("https://scsanctions.un.org/resources/xml/en/consolidated.xml")),
INDIVIDUALS = Source{0}[INDIVIDUALS],
INDIVIDUAL = INDIVIDUALS{0}[INDIVIDUAL],
#"Expanded LAST_DAY_UPDATED" = Table.ExpandTableColumn(INDIVIDUAL, "LAST_DAY_UPDATED", {"VALUE"}, {"VALUE"}),
#"Expanded VALUE" = Table.ExpandTableColumn(#"Expanded LAST_DAY_UPDATED", "VALUE", {"Element:Text"})
in
#"Expanded VALUE"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Surm, just write another Table.ExpandTableColumn manualy:
Output:
let
Source = Xml.Tables(Web.Contents("https://scsanctions.un.org/resources/xml/en/consolidated.xml")),
INDIVIDUALS = Source{0}[INDIVIDUALS],
INDIVIDUAL = INDIVIDUALS{0}[INDIVIDUAL],
#"Expanded LAST_DAY_UPDATED" = Table.ExpandTableColumn(INDIVIDUAL, "LAST_DAY_UPDATED", {"VALUE"}, {"VALUE"}),
#"Expanded VALUE" = Table.ExpandTableColumn(#"Expanded LAST_DAY_UPDATED", "VALUE", {"Element:Text"})
in
#"Expanded VALUE"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@dufoq3 ,
Do you have a solution to expanding the "DESIGNATION" column?
This is the problem:
"DESIGNATION" xml element sometimes has 1 child, sometimes 2 or more children.
After expanding the column, it shows the expanded value when there is 1 child, otherwise shows "[Table]". There is no icon on the column header to Expand again.
I tried your previous trick and manually added another Table.ExpandTableColumn, however, it produces the error below. Looks like when the column is a simple text, it fails this time because it is not a table?
Are you able to explain why this error occurs in the first place? Is this a bug in Power Query or is this how it is supposed to work?
To fix this, I suppose an "IF" condition is required, but I am not sure how to write it.
Helpful resources
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Microsoft Fabric Community Conference 2025
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
Subject | Author | Posted | |
---|---|---|---|
04-15-2024 07:30 PM | |||
05-27-2024 05:52 AM | |||
Anonymous
| 07-24-2023 03:33 PM | ||
03-02-2024 03:37 AM | |||
08-09-2024 07:30 AM |