Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Is it possible to use the import from folder for multiple XML files? I have manged to extract the data I need from a single XML file using "import from XML" but not with the files from folder. Thank you!
Solved! Go to Solution.
The way I usually do it is with 2 queries: a folder query to get the paths/names of the files, and a function query to parse them.
Steps:
let Source = Folder.Files("C:\XML Files"), #"Removed Other Columns" = Table.SelectColumns(Source,{"Name", "Folder Path"}), #"Added Custom" = Table.AddColumn(#"Removed Other Columns", "Path", each [Folder Path] & [Name]), #"Added Custom1" = Table.AddColumn(#"Added Custom", "XML Data", each getXML([Path])), #"Expanded XML Data" = Table.ExpandTableColumn(#"Added Custom1", "XML Data", {"TITLE", "ARTIST", "COUNTRY", "COMPANY", "PRICE", "YEAR"}, {"TITLE", "ARTIST", "COUNTRY", "COMPANY", "PRICE", "YEAR"}) in #"Expanded XML Data"
Folder Query
(path as text) => let Source = Xml.Tables(File.Contents(path)), Table0 = Source{0}[Table], #"Changed Type" = Table.TransformColumnTypes(Table0,{{"TITLE", type text}, {"ARTIST", type text}, {"COUNTRY", type text}, {"COMPANY", type text}, {"PRICE", type number}, {"YEAR", Int64.Type}}) in #"Changed Type"
Message me if you would like an example PBIX file that does this
Alex
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
106 | |
105 | |
88 | |
75 | |
66 |
User | Count |
---|---|
126 | |
111 | |
100 | |
83 | |
71 |