问题
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.
- Add a parameter and allow load for it. (for example its name is Query_param_1)
- Create query in Import mode (only this mode allows it)
- Then open extendet editor for created query
- Edit "query part:
- [Query="EXEC [rpt].[sp_rpt_bids_statictics_2] @DateFrom = '"Query_param_1"'"]
- 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