Forum Discussion
How to pass a parameter to a MySQL stored procedure from powerBI
Hey ebjm
Hopefully this can help you out. I wrote this reply on another thread:
"It turns out that this is actually possible in Power BI. I've created a walkthrough video on how to do this here.
The basic gist is to add an R visual that takes in your slicer selection as its value. There is an R package called RODBC that can run SQL code against your database. You can then pass your slicer value into the SQl query using some string interpolation or the "paste" function. Let me know how this works for you."
You will need to change the connection type from SQL Server to MySQL.
Hope this helps,
Parker
Thanks but I am puzzled. Why can I pass the following from Power BI to my MySQL server?
CALL my_sp();
but I am not allowed to pass
SET @p0 = 'xyz';
CALL my_sp(@p0);
- Anonymous8 years agoNot applicable
How are you passing it?
- ebjm8 years agoRegular Visitor
I pass it through the 'SQL statement' text field after 'Get Data'.
- Anonymous8 years agoNot applicable
I'm not too familiar with MySQL but when connecting to SQL Server, Power BI will wrap the entire command in a SELECT.
That leads me to believe that
SELECT
*
FROM (CALL my_sp();
)will work but the following won't:
SELECT * FROM (SET @p0 = 'xyz'; CALL my_sp(@p0); )
Maybe that's the reason for your troubles. But like I said in an earlier post, take a look at my video and you can get around your issue if your situation fits. It involves using an R visual to run your SP instead of the Get Data function of Power BI.
Hope this helps,
Parker