Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

parameters to SP or Sql query

There is probably a simple answer but after looking all over for an answer and trying various methods, the right code still escapes me.  The scenario is I have a stored procedure that uses two input parameters, a start and end date. If I hard code the date in the call, getting the data works fine. I defined two parameters in Power BI and have been trying to figure out how to call the SP with these 2 paramters. My paramters are named Sdatex and Edatex. Both are defined as date type variables.

here is my call that works:

DECLARE @return_value int

EXEC @return_value = [dbo].[Capacity_SP]

@SDate = '8/11/2016',

@EDate = '8/12/2016'

SELECT 'Return Value' = @return_value


I also tried to execute the SP code (a CTE) insted of the SP and I have the same issue. Hard coded dates work but I do not know how to tell Power BI that I want the paramters (Sdatex and Edarex) used instead of the date.

Any help would be appreciated.


Hi Sven, just dont add the "Text.ToText" part. it's already text.


for example:


    SQLSource = (param1 as text, param2 as date) =>
    Source = Sql.Database("MyServer", "MyDatabase", [Query="exec [MyDatabase].[dbo].[myProc] '"& param1 & "','" & Date.ToText(param2)&"'"])

 I hope this helps.



Thank you Alan - can't believe I missed the obvious!  Thank you for putting the response on, am sure it will help others out too.

Hi @v-yuezhe-msft,


I'm dealing with something like this but this doesn't work for me. I want, in the step 3, fill these values with the value from an app. It's is possible? Full post is available here.

Thanks in advance


Guys do we've a solution for this, I've similar requirement, I've got four drop downs in my report


1. Country

2. State

3. City

4 Store


the navigation is working fine, but I've a requirement to take this to next level i.e. in each drop down I've option to select either one or all, now once the selection is made, I want to use this as a input parameter for a stored procedure which resides in my sql server database.

I understand that in the new query editor I can use the stored procedure but how do I populate the parameter from the drop down visualization i.e. slicer in my case (I can use some other visualization aslo), first will list country, second will have states, third will have city and fourth will have storeIDs, now I can either have all selected or any indivudial values and on the basisi of this select tion, my procedure should execute like below


exec dbo.myproc countryid = @countryvar,  stateid = @statevar, cityID = @cityID, storeDi = @storeID



SQLSource = (Start_Date as date, End_Date as date, Fund_Name as text) =>



Not sure... is this what you were looking?

Not applicable


Guys, you dont need to use Text.ToText, It is required for only non text values. 

for example: '"& VariableName & "'

Not applicable


Guys, you dont need to use Text.ToText, It is required for only non text values. 

for example: '"& VariableName & "'

I use like  '"&Text.From(Period)& "'

I use like  '"&Text.From(Period)& "'

Seems this is a solution for PBI desktop only.

Dont know what will be the benifit of this if we have to modify parameter every time a new range of data is required and then publish the report. 


I was looking for similar implementation in service side but no success so far.

Helpful resources

November Update

Check it Out!

Click here to read more about the November 2020 Updates!

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!


Power Platform October Community Highlights

Check out the top community contributors across all of the communities


Create an end-to-end data and analytics solution

Learn how Power BI works with the latest Azure data and analytics innovations at the digital event with Microsoft CEO Satya Nadella.

Top Solution Authors
Top Kudoed Authors