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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
juanmfarinas
Frequent Visitor

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
juanmfarinas
Frequent Visitor

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
juanmfarinas
Frequent Visitor

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
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

Top Solution Authors
Top Kudoed Authors