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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
MeganM11
New Member

Using parameter as data source

Hi,

 

For some reason Power Query does not allow me to use a parameter as a datasource when using the following code:

Source = Excel.Workbook(File.Contents(Model_datasource), null, true)

 Where "Model_datasource" is the parameter referencing a cell in the excel workbook.

 

In order to get it to work I have to use the following code:

 

FilePath=Excel.CurrentWorkbook(){[Name="Model_datasource"]}[Content]{0}[Column1],

   

Source = Excel.Workbook(File.Contents(#"FilePath"), null, true),

 

Where "Model_datasource" is the excel named cell.

 

Why is it not working as a parameter? Is it something it a privacy issue?

 

Please note that the folderpath is linked to a company sharepoint folder.

3 REPLIES 3
Anonymous
Not applicable

Hi @MeganM11 ,

 

Please see the blog below and JM's reply below, I hope it helps.

vcgaomsft_0-1725342798542.png

Change the Power Query source based on a cell value

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

PwerQueryKees
Super User
Super User

What is the content of the parameter? It should be a path to the excel file. 

And once you got that, you still have to find the cell in you workbook.

So, first solution gets you an error or en excel file as Source and second solution gets you some content from the workbook containing the query.

This is how it is supposed to work. 

Excel.Workbook and Excel.CurrwntWorkbook return the same type of date, so you should use their results the same...

The content of the parameter is an excel file path.

 

Thanks for the explanation. The weird thing is that the first query using Excel.Workbook and using the parameter directly without having the extra step of creating the FilePath works for my colleague linking to the same excel file.

 

That's why I am uncertain why the same query does not work for me without the work around.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.