Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

Merge xlsx files and filter empty files.

Hi everyone!

 

I have a query than combine xlsx from a folder of sharepoint online. The files arrives automatically.

 

Files usually have several columns with data. But in some cases arrives files with no info, and the format is just the first row:

"No results returned."

 

How can i filter that files? I guess, when I make Table.SelecRows I should put some kind of filter, but how?

 

Thanks in advance!

 

 

 

let
  Source = SharePoint.Files("https://xxxx.sharepoint.com/teams/xxxx/", [ApiVersion = 15]),
  #"Filtered rows" = Table.SelectRows(Source, each [Folder Path] = "https://xxxx.sharepoint.com/teams/xxxx/folder/folder/"),
  #"Expanded Attributes" = Table.ExpandRecordColumn(#"Filtered rows", "Attributes", {"Size"}, {"Attributes.Size"}),
  #"Filtered hidden files" = Table.SelectRows(#"Expanded Attributes", each [Attributes]?[Hidden]? <> true),
  #"Invoke custom function" = Table.AddColumn(#"Filtered hidden files", "Transform file", each #"Transform file"([Content])),
  #"Renamed columns" = Table.RenameColumns(#"Invoke custom function", {{"Name", "Source.Name"}}),
  #"Removed other columns" = Table.SelectColumns(#"Renamed columns", {"Source.Name", "Transform file"}),
  #"Expanded table column" = Table.ExpandTableColumn(#"Removed other columns", "Transform file", Table.ColumnNames(#"Transform file"(#"Sample file"))),
  #"Transform columns" = Table.TransformColumnTypes(#"Expanded table column", {{XXXX}}),
  #"Replace errors" = Table.ReplaceErrorValues(#"Transform columns", {{XXXXX}})
in
  #"Replace errors"

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I find a solution. When I filter the files, I select those that have more than 2 columns.

 

#"Filtered rows" = Table.SelectRows(Source, each [Folder Path] = "https://xxxx.sharepoint.com/teams/xxxx/xxxx/" and Table.ColumnCount(Excel.Workbook([Content], null, true){[Item = "Sheet_name", Kind = "Sheet"]}[Data])>2)

View solution in original post

1 REPLY 1
Anonymous
Not applicable

I find a solution. When I filter the files, I select those that have more than 2 columns.

 

#"Filtered rows" = Table.SelectRows(Source, each [Folder Path] = "https://xxxx.sharepoint.com/teams/xxxx/xxxx/" and Table.ColumnCount(Excel.Workbook([Content], null, true){[Item = "Sheet_name", Kind = "Sheet"]}[Data])>2)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.