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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
Anonymous
Not applicable

Create a parameter named DataSourceExcel that

You create a parameter named DataSourceExcel that holds the file name and location of a Microsoft Excel data source.
You need to update the query to reference the parameter instead of multiple hard-coded copies of the location within each query definition.
Solution: In the Power Query M code, you replace references to the Excel file with DataSourceExcel.
Does this meet the goal?

  • A. Yes
  • B. No
1 ACCEPTED SOLUTION
BedhiafiAmira
Frequent Visitor

Let's imagine this scenario, If we have 5 queries, each of them pointing to the same Excel file. If we need to change Excel file location using M code, we need to go to advanced editor for each query and hard-code location of new Excel file. We need to repeat it each time we change the data source.

 

If we create just 1 parameter and use this parameter name instead of hard-code Excel location in each query, once we change parameter value (only on one place), it will update automatically all 5 queries. So we will have to change reference from hard-coded value to parameter on each query, but we do this only once, after that ew change only parameter value on 1 place.

 

 

Yes it does meet the goal. This is a simple example :

I imported an Excel file first without using a parameter and copied it twice, now I have 3 tables pointing to the same Excel file : (This is another way as I am supposing your question is related the to certification exam)

 

let
Source = let
Source = Excel.Workbook(File.Contents("XXXXXX\Sample Data 1.xlsx"), null, true),
Emp_Sheet = Source{[Item="Emp",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Emp_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"EmpID", type text}, {"Name", type text}, {"Month", type date}})
in
#"Changed Type"
in
Source

 

BedhiafiAmira_0-1660570842848.png

Then I created a parameter pointing to the location of that file :

BedhiafiAmira_1-1660570908389.png

 

and I updated the code of each query like below : DataSourceExcel is the variable containing the path of the Excel file :

 

 

= let
Source = Excel.Workbook(File.Contents(DataSourceExcel), null, true),
Emp_Sheet = Source{[Item="Emp",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Emp_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"EmpID", type text}, {"Name", type text}, {"Month", type date}})
in
#"Changed Type"

 

To conclude the answer is No.

View solution in original post

1 REPLY 1
BedhiafiAmira
Frequent Visitor

Let's imagine this scenario, If we have 5 queries, each of them pointing to the same Excel file. If we need to change Excel file location using M code, we need to go to advanced editor for each query and hard-code location of new Excel file. We need to repeat it each time we change the data source.

 

If we create just 1 parameter and use this parameter name instead of hard-code Excel location in each query, once we change parameter value (only on one place), it will update automatically all 5 queries. So we will have to change reference from hard-coded value to parameter on each query, but we do this only once, after that ew change only parameter value on 1 place.

 

 

Yes it does meet the goal. This is a simple example :

I imported an Excel file first without using a parameter and copied it twice, now I have 3 tables pointing to the same Excel file : (This is another way as I am supposing your question is related the to certification exam)

 

let
Source = let
Source = Excel.Workbook(File.Contents("XXXXXX\Sample Data 1.xlsx"), null, true),
Emp_Sheet = Source{[Item="Emp",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Emp_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"EmpID", type text}, {"Name", type text}, {"Month", type date}})
in
#"Changed Type"
in
Source

 

BedhiafiAmira_0-1660570842848.png

Then I created a parameter pointing to the location of that file :

BedhiafiAmira_1-1660570908389.png

 

and I updated the code of each query like below : DataSourceExcel is the variable containing the path of the Excel file :

 

 

= let
Source = Excel.Workbook(File.Contents(DataSourceExcel), null, true),
Emp_Sheet = Source{[Item="Emp",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Emp_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"EmpID", type text}, {"Name", type text}, {"Month", type date}})
in
#"Changed Type"

 

To conclude the answer is No.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

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.

Top Solution Authors