Share via

Importing from Folder

ron barlow 411 Reputation points
2020-12-26T09:47:19.15+00:00

Hello

I want to import multiple files form the same folder. I've added a custom column, but this is giving me an error. M code and errors are ...

Source = Folder.Files("E:\StudentTest"),
#"Removed Other Columns" = Table.SelectColumns(Source,{"Content", "Name"}),
#"Added Custom" = Table.AddColumn(#"Removed Other Columns", "ExcelData", each Excel.Workbook[Content])
in
#"Added Custom"

Expression.Error: We cannot apply field access to the type Function.
Details:
Value=[Function]
Key=Content

Any advice
much appreciated.
Ron

Community Center | Not monitored
0 comments No comments

Answer accepted by question author

Lz365 38,201 Reputation points Volunteer Moderator
2020-12-26T10:31:34.007+00:00

Hi @ron barlow

You're missing a closing parenthese after Excel.Workbook. The following should do what you want:

let  
    Source = Folder.Files("E:\StudentTest"),  
    #"Removed Other Columns" = Table.SelectColumns(Source,{"Content", "Name"}),  
    #"Added Custom" = Table.AddColumn(#"Removed Other Columns", "ExcelData", each Excel.Workbook([Content]), type table)  
in  
    #"Added Custom"  

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. ron barlow 411 Reputation points
    2020-12-26T15:20:01.72+00:00

    Thanks you for the quick reply, which has worked.

    I used the ribbon to build the Custom column (I didn't type it manually), so I'm not sure why PBI didn't add the missing piece of M code?

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.