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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric 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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Top Solution Authors
Top Kudoed Authors