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
MartinvanK2023
Regular Visitor

Excel Power Query Expression Error

I have the following issue. I created a query based on Excel file Invoice with a specific name. But when I replace in the source folder a different file with a different name the query gives an Expression error. I understand what the issue is but I would like to know how I can solve it? I have example files ready and an explanation in Word but I do not see how I can attach them yet.

 

With kind regards,

Martin

9 REPLIES 9
eduardosa
Frequent Visitor

Hi Martin,

 

Question, can you paste the error on the message?

 

There are a couple of suggestions you can try, depending on the scenario:

  • change the file location to a parameter,
  • choose data source to folder.

But please explain better what you're trying to achieve.

 

Regards,

Eduardo

Hello Eduardo,

I have a file available with all the print screens of the steps I took but at the end this error message appears. 

 

Expression.Error: The column 'Example Invoice 1.xlsx' of the table wasn't found.
Details:
Example Invoice 1.xlsx

 

The file is located in a folder (the data source is a folder) but when I remove the file with Example Invoice 1  and replace it with Example Invoice 2 this error occurs. The query is looking for Example Invoice 1 but it cannot locate it anymore.

If you're using folder as a data source, have you pressed binary instead of expanding the content?

 

This will enable you to combine the content of every/any excel file in the folder.

If you pressed binary, it will generate an error, because this is hard coded.

 

eduardosa_0-1681822617444.png

 

 

Hello Eduardosa

 

MartinvanK2023_3-1681889470671.png

This how currently the source looks, the source is a folder. The document name in the folder is Example Invoice 1

 

MartinvanK2023_1-1681888067404.png

Here I choose Commercial Invoice (tab) and open the table.

MartinvanK2023_4-1681889591639.png

I filter out the rows I do not need. It now shows the rows I need.

MartinvanK2023_5-1681889661006.png

And here I promote the first line to headers.

But when I replace in the folder the Example Invoice 1 file with Example Invoice 2 the query gives an error as it still looking for file Example Invoice 1 despite it is in a folder. I also checked the message of Solution Sage I do not understand that one.

 

Hi @MartinvanK2023 ,

 

Replace your steps with combine files (this option is not that obvious).

 

eduardosa_0-1681892052680.png

 

This will create the transformation steps which will apply to any file you drop on the folder.

Hi Eduardosa,

I initially did that and I got the error message I posted here.

MartinvanK2023_0-1681894515952.png

 

MartinvanK2023_1-1681894612814.png

This creates the source name to be the Example Invoice 1 file.

MartinvanK2023_2-1681896399272.png

The following steps are the same. Filter out the lines you do not need. Promote the first line as header. Then close and load.

 

MartinvanK2023_3-1681896683380.png

But when I then replace the Example Invoice 1 by the Example Invoice 2 in the folder. I get the error message when I refresh the data in the table.

MartinvanK2023_4-1681896848128.png

As the query is still looking fot Example Invoice 1.

Following the step Promoted Headers, rename first column to "File Name".

 

 

Hello Eduardosa,

Thank you for responding. The problem still remains. The column is not dynamic. Is should not look at this specific file but to all data that is in the folder....

MartinvanK2023_0-1682079670760.png

MartinvanK2023_1-1682080043350.png

 

You query likely has a step that directly references that file name. In the query editor, find the earliest step that gives the error and look in the formula bar. You can update the hard-coded file name there, or you can learn how to do a relative reference (e.g., {0} to get the first row/record of the table).

 

Pat

Microsoft Employee

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

Top Solution Authors
Top Kudoed Authors