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.
Solved! Go to Solution.
Hi Sven, just dont add the "Text.ToText" part. it's already text.
let SQLSource = (param1 as text, param2 as date) => let Source = Sql.Database("MyServer", "MyDatabase", [Query="exec [MyDatabase].[dbo].[myProc] '"& param1 & "','" & Date.ToText(param2)&"'"]) in Source in SQLSource
I hope this helps.
Guys do we've a solution for this, I've similar requirement, I've got four drop downs in my report
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
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.
Check out the on demand sessions that are available now!
Check out the Winners!
Learn how Power BI works with the latest Azure data and analytics innovations at the digital event with Microsoft CEO Satya Nadella.