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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
snandy2011
Helper IV
Helper IV

Excel.Workbook function not working

Hi,

I am just importing multiple excel file from a folder.For that, I have wriiten a simple M function Excel.Workbook, but it does not work. It shows "The formula is incomplete".

See the below screenshot,

Capture.JPG                                                  

My formula is so simple : =Excel.Workbook([Content],true).

I have written above same formula  into  excel's power query  and it works fine.It does not show me any error.But in power Bi'spower query it does not work.

I dont understand why it is not working. If the same formula works in excel, then why it is not working in power BI?

Can you please suggest me what wrong I have done?

Any suggesation is really appreciable.

 

Thanks,

snandy

1 ACCEPTED SOLUTION

@snandy2011 ,

 

This as to do with the way you setup your function, if you do it from scratch you need to adjust the way of working.

 

When having a link from a folder if you notice the first step on the function is what you refer:

 

  Source = Excel.Workbook([content], null, true),

However in the combination of the files the first step is:

= Folder.Files("C:\Folder")

And you invoke the custom function from the C:\Folder.

 

So you are refering the folder path, however this depends on how you setup your function.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

4 REPLIES 4
MFelix
Super User
Super User

Hi @snandy2011,

Whe you used powerqueryit was in the file were you have the data correct?

In PBI part of the information is the location of the file so you need something like this

Excel.Workbook(File.Contents("C:\Projects\Examples\Customers and Orders.xlsx"), true),

Customers_Sheet = Source{[Item="Customers",Kind="Sheet"]}[Data]

So you need to define location of file.

But if you are making a query to get files from folder why don't you use the functionality from PBI it will create the code for you

https://docs.microsoft.com/en-us/power-bi/desktop-combine-binaries

If it's for learning purposes then you can analize the code created.

Regards,
MFelix

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



hi @MFelix ,

 

Thanks for replying.. i have used combine features before on PBI.but,my question was that, why the same code is not working on PBI,while it is working fine on Excel..yeah, on PBI, i have to do a little bit extra.that is, mentioning the location of the file.

 

anyway, Thanks for replying..

 

Regards,

snandy

looking at the formula description in #shared it does have 3 arguments, but only 1st one is mandatory (binary), and on my side I couldn't replicate the issue when passing only 2 arguments. Could it be that one of the binaries is not Excel?
Capture.PNG

maybe try something like

Excel.Workbook([Content], true, null)

 



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

@snandy2011 ,

 

This as to do with the way you setup your function, if you do it from scratch you need to adjust the way of working.

 

When having a link from a folder if you notice the first step on the function is what you refer:

 

  Source = Excel.Workbook([content], null, true),

However in the combination of the files the first step is:

= Folder.Files("C:\Folder")

And you invoke the custom function from the C:\Folder.

 

So you are refering the folder path, however this depends on how you setup your function.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.