Showing results for 
Search instead for 
Did you mean: 
Helper III
Helper III

Need to pass the variables dynamically into sql script as a source into Power BI Desktop

Hi Team,

I have a script which has the date variable mentioning as below image which are highlighted . If I pull this script into Power BI Desktop(SQL Source-Query) How can I pass the values into this variable from Power BI Desktop using the filter Slicer. Please do the needful asap as I have ambiguity on this .Thank You so Much.



Community Support
Community Support

Hi @chandru123 ,


Please take a look at the following link to see if it helps, and hopefully some other expert in Power BI will be able to solve it.




Hope it helps,

Community Support Team _ Caitlyn

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

Helper III
Helper III

Hi Team,

This is the simple exampel to understood

Declare @Employee varchar(max)

Set @Employee = 'Filter Value from Slicer Visual from Power BI'

Select top 10
EmployeeID,EmployeeAddress from Employee where EmployeeName=@Employee

If we select Employee = 'Dhoni' from Power BI Slicer Visual , the sql source script should as follows

Declare @Employee varchar(max)

Set @Employee = 'Dhoni'

Select top 10
EmployeeID,EmployeeAddress from Employee where EmployeeName='Dhoni'

If we pass multiple values like Employee = Dhoni,Kohli then the sql query should be as follows 

Declare @Employee varchar(max)

Set @Employee = 'Dhoni','Kohli'

Select top 10
EmployeeID,EmployeeAddress from Employee where EmployeeName in ('Dhoni','Kohli')

Please do the needful . Thank You.

I have seen this from different source and its posted in 2016 . I hope any chances that can available now



Helpful resources

2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors