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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
scott_Abaana
Helper I
Helper I

Setting a Parameter to the value of a cell

Is there a way to assign the value of a cell (lets say in sheet 1  A1) to a parameter?

 

Normally I just type in the value of the parameter, but I would like to be able to change it based on the value in cell A1

6 REPLIES 6
mahoneypat
Microsoft Employee
Microsoft Employee

Is your PATH parameter set to type text or list?

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


scott_Abaana
Helper I
Helper I

OK I think I have it working now.

 

There seems to be two ways (or at least two)

 

1. If i name the Cell with the File location "FilePath" this seems to set a variable "FilePath" to equal this cell.

FilePath = Excel.CurrentWorkbook(){[Name="FilePath"]}[Content]{0}[Column1], Source = Excel.Workbook(File.Contents( FilePath & "BOOK2.xlsx"), null, true),

 

I was able to bring in a Table with the same information and drill down and it seems to be a text variable called Table2

I assumed that if I just put this in the formula 

 

Source = Excel.Workbook(File.Contents( Table2 & "BOOK2.xlsx"), null, true)

 

But it doesnt seem to like it:

 

scott_Abaana_0-1610971441603.png

 

Looks like that should work.  Does Table2 have a "\" at the end of it?

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


mahoneypat
Microsoft Employee
Microsoft Employee

Not sure why that is being recognized as a little.  Can you share all your M code from the advanced editor?  Also describe your scenario further so perhaps a simpler way can be suggested.

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


mahoneypat
Microsoft Employee
Microsoft Employee

You can just use the result of a query that returns a text value where you would use a parameter.  Bring in the cell into a query and then drill down as the last step (right click option) and the query will return a text value (or date or number).  You can then just use the name of that query where you would a parameter.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


OK, Not sure I am doing this right. What I am trying to create is portable power queries.

 

Currently I set the folder location to a parameter called "PATH"

 

EG  PATH =  

C:\Users\Scott\OneDrive\Desktop\TEST\1\


So I would then use:

 

Excel.Workbook(File.Contents( PATH & "BOOK2.xlsx"), null, true)

 

I have found that I can create a function in Excel which updates this location in a Cell  which means if I change the folder names it should update when I move the PQ between machines.

 

So I tried to do the above, but  I think it turned it into a Numerical List

 

 

Expression.Error: We cannot apply operator & to types List and Text.
Details:
Operator=&
Left=[List]
Right=BOOK2.xlsx

 

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors