Power BI. Execute SQL Server stored procedure with a user parameter

被刻印的时光 ゝ 提交于 2019-12-23 02:38:08

问题


I have a Power BI report and a stored procedure with a @DateFrom parameter which returns a number of rows. I want to allow user to choose the date which will be passed to stored procedure. (Using DirectQuery mode)

I have fount zero solutions to this simple task. Maybe I don't understand anything, but it's quite a common problem, which seems to be ignored by Power BI developers.

Here is my stored procedure:

EXEC [rpt].[sp_rpt_bids_statictics_2] @DateFrom = '20160101'

Now I want to allow user to choose that very date, fore example '20160501' and then the query will be the following:

EXEC [rpt].[sp_rpt_bids_statictics_2] @DateFrom = '20160501'

is it possible in Microsoft Power BI?


回答1:


Ok, I have found the solution.

  1. Add a parameter and allow load for it. (for example its name is Query_param_1)
  2. Create query in Import mode (only this mode allows it)
  3. Then open extendet editor for created query
  4. Edit "query part:
  5. [Query="EXEC [rpt].[sp_rpt_bids_statictics_2] @DateFrom = '"Query_param_1"'"]
  6. Now it works with the parameter, chosen by user.


来源:https://stackoverflow.com/questions/41375902/power-bi-execute-sql-server-stored-procedure-with-a-user-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!