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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
GrahamR99
Resolver I
Resolver I

SQL Query with Parameter

Hello

I'm trying to put a paramenter in my SQL Query so I have change the code to this.

 

let
    Source = Sql.Database("FRV", "DW", [Query="Select *#(lf)from [dbo].[FactRetailSales] FRS#(lf)Inner Join [dbo].[DimRetailProduct] DRP on FRS.Product_ID = DRP.Product_ID#(lf)Inner Join [dbo].[DimDate] DD on FRS.Sale_Date = DD.DateKey#(lf)Where DD.Year = '" &Year_Select&"'"])
in
    Source

 

Year_Select is my parameter.

 

However I am getting this error.

 

Formula.Firewall: Query 'Sales_Data' (step 'Source') references other queries or steps, so it may not directly access a data source. Please rebuild this data combination.

 

Does anyone know how I resolve the problem?

 

Regards

 

GrahamR99

2 REPLIES 2
v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @GrahamR99,

The error message means there is a problem about Query 'Sales_Data', please follow the steps here to troubleshooting it. From your statement, the passed paramenter statement syntax is right. You can check how to Pass parameter to SQL Queries statement using Power BI in this vedio.

In addition, I post two similar articles for your reference.

Formula.Firewall: Query references other queries, so it may not directly access a data source. 
How do I pass parameters to my SQL statement?

Best Regards,
Angelia

Hello Angelia

I have followed how to set a parameter video, I still get the same issue.

 

The trouble shooting page is not much help as I am querying SQL server not Excel and my parameter is in the first line of the SQL code.

 

Do you have any more help?

 

Regards

 

GrahamR99

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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