Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Hi,
I am trying to use Import - Folder to pull a list of files in a folder/sub folders so I can do some analysis of the file types and where they are stored. I'm running into an issue where there are stupid long file paths:
DataFormat.Error: The file name '\\server\share\folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\*' is longer than the system-defined maximum length.
I tried using "replace errors" in the query editor but that didn't work.
Anyone have any ideas?
Dan
Solved! Go to Solution.
Hi @robofski ,
1. Create a parameter in Power query make the parameter is \\server\share\folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder.
2. Edit the M code in your Advanced editor to replace the file pate to parameter.
let Source = Folder.Files(""&Parameter1), #"Filtered Hidden Files1" = Table.SelectRows(Source, each [Attributes]?[Hidden]? <> true), #"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files1", "Transform File from New folder", each #"Transform File from New folder"([Content])), #"Renamed Columns1" = Table.RenameColumns(#"Invoke Custom Function1", {"Name", "Source.Name"}), #"Removed Other Columns1" = Table.SelectColumns(#"Renamed Columns1", {"Source.Name", "Transform File from New folder"}), #"Expanded Table Column1" = Table.ExpandTableColumn(#"Removed Other Columns1", "Transform File from New folder", Table.ColumnNames(#"Transform File from New folder"(#"Sample File"))), #"Changed Type" = Table.TransformColumnTypes(#"Expanded Table Column1",{{"Source.Name", type text}, {"Date", type date}, {"cat", type text}, {"Sales", Int64.Type}}) in #"Changed Type"
Hi guys, I was struggling with a similar problem, and I've just found a solution.
I was trying to import all of my folders, so that I could filter and use certain files.
Filtering directly on the file type (.xlsx) was giving this DataFormat error, since it was looking at all of my files, some of which are pdfs with long names or folders inside folders..
Luckily, all the files I wanted to combine were all in folders that have a similar naming convention, e.g. '- 2024 -', I was able to filter on the Filepath instead, only looking for folders which contained the right type of name.
This meant that less files were being considered, and I suppose this filtered out some of the long file names (e.g. pdfs) which were causing the problem.
Hi @robofski ,
1. Create a parameter in Power query make the parameter is \\server\share\folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder.
2. Edit the M code in your Advanced editor to replace the file pate to parameter.
let Source = Folder.Files(""&Parameter1), #"Filtered Hidden Files1" = Table.SelectRows(Source, each [Attributes]?[Hidden]? <> true), #"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files1", "Transform File from New folder", each #"Transform File from New folder"([Content])), #"Renamed Columns1" = Table.RenameColumns(#"Invoke Custom Function1", {"Name", "Source.Name"}), #"Removed Other Columns1" = Table.SelectColumns(#"Renamed Columns1", {"Source.Name", "Transform File from New folder"}), #"Expanded Table Column1" = Table.ExpandTableColumn(#"Removed Other Columns1", "Transform File from New folder", Table.ColumnNames(#"Transform File from New folder"(#"Sample File"))), #"Changed Type" = Table.TransformColumnTypes(#"Expanded Table Column1",{{"Source.Name", type text}, {"Date", type date}, {"cat", type text}, {"Sales", Int64.Type}}) in #"Changed Type"
Hi, I created the parameter and pasted the M code in the advanced editor. I get another error then:
Can you help me with that? 🙂
I have the same problem but sadly this solution does not work for me.
it´s like the small link is always the same
\\server\share\folder\another folder\another folder
and than comes long link with different folders
\folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder\another folder.....
so even with Parameter its too long.
need Halp
I would like to combine Excel files from different folders as a one list.
Hi Nodari
I amalso struggling with this as the proposed solution is not working for me.
Just wondering if you have managed to find a solution?
Many thanks
The same for me. was there any other solution?
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
88 | |
77 | |
57 | |
41 | |
39 |