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.
I made a test to call stored procedure with parameters in Power BI Desktop. You can review the following example to apply it to your scenario.
In SQL Server, I create a procedure named p4test in test database of v-kaxion2015tes\sql2016tabular server.
Create PROC p4test @sdate date,@edate date AS BEGIN SELECT @sdate StartDate, @edate Enddate END
1. In Query Editor of Power BI Desktop, click "New source"> "SQL Server", enter server name, database name and statement "exec p4test '8/11/2016', '8/12/2016'", click ok.
2. Right click on that query on the left panel and select Advanced Editor, and paste the below code.
let SQLSource = (param1 as date, param2 as date) => let Source = Sql.Database("v-kaxion2015tes\sql2016tabular", "test", [Query="exec p4test '"& Date.ToText(param1) & "','" & Date.ToText(param2)&"' #(lf)#(lf)#(lf) #(lf)"]) in Source in SQLSource
3.Click “Invoke” button and enter parameter values as shown in the following screenshot.
@v-yuezhe-msft: May i know how this works in Power BI Service. If it is not going to work in Power BI Service, then is there any alternative to achieve the same kind of functionality in Power BI Service
Can any one Plz help me out ,
Is it possible to get the Invoke function , like as a parameter in desktop to pass i/p value as a parameter to my direct query (SP) .
Based on that i/p value my data has to be refreshed or updated .
Is it possible to desible the "Refresh data" or "Edit Permission" warnings messages always .
Join us in the third Triple A event!
It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.
Make sure you didn't miss any of the things that happened in the community in January!