Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
powerbidev123
Solution Sage
Solution Sage

Issue while using stored procedure in SQL server database

image (2).png

 

Hi community,

 

Is there a way to fix this because manually inserting the customerid works but when I try to make it parameterized then it gives the above error

 

Any kind of suggestion would be helpful

 

Thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @powerbidev123 ,

 

Thanks for the reply from girishthimmaiah .

 

Assuming that your

Server = X

Database = Y

Table name = Z

 

The sample SQL query is (as if you put it on SSMS)

select *
from z
WHERE [customerid]=2

vhuijieymsft_0-1739517496647.png

 

The conversion to M-code is:

let
    Source = Sql.Database("vm1", "TutorialDB", [Query="select *#(lf)from Customers#(lf)WHERE [customerid]=2#(lf)"])
in
    Source

vhuijieymsft_1-1739517496648.png

 

Now, if you want to pass parameters to the where clause as Parameter1, (e.g. Parameter1 =2) make sure they are text first.

vhuijieymsft_2-1739517513849.png

 

You can create a custom query as follows:

let
    Source = Sql.Database("x", "y", [Query="select *#(lf)from z#(lf)WHERE [customerid]="&Parameter1&"#(lf)"])
in
    Source

vhuijieymsft_3-1739517513850.png

 

If you have any other questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @powerbidev123 ,

 

My following up is just to ask if the problem has been solved?

 

If so, can you accept the correct answer as a solution or share your solution to help other members find it faster?

 

Thank you very much for your cooperation!

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Anonymous
Not applicable

Hi @powerbidev123 ,

 

My following up is just to ask if the problem has been solved?

 

If so, can you accept the correct answer as a solution or share your solution to help other members find it faster?

 

Thank you very much for your cooperation!

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Anonymous
Not applicable

Hi @powerbidev123 ,

 

Thanks for the reply from girishthimmaiah .

 

Assuming that your

Server = X

Database = Y

Table name = Z

 

The sample SQL query is (as if you put it on SSMS)

select *
from z
WHERE [customerid]=2

vhuijieymsft_0-1739517496647.png

 

The conversion to M-code is:

let
    Source = Sql.Database("vm1", "TutorialDB", [Query="select *#(lf)from Customers#(lf)WHERE [customerid]=2#(lf)"])
in
    Source

vhuijieymsft_1-1739517496648.png

 

Now, if you want to pass parameters to the where clause as Parameter1, (e.g. Parameter1 =2) make sure they are text first.

vhuijieymsft_2-1739517513849.png

 

You can create a custom query as follows:

let
    Source = Sql.Database("x", "y", [Query="select *#(lf)from z#(lf)WHERE [customerid]="&Parameter1&"#(lf)"])
in
    Source

vhuijieymsft_3-1739517513850.png

 

If you have any other questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

girishthimmaiah
Resolver I
Resolver I

80% of your text is likely AI-generated

New version:
It seems that Power BI is attempting to execute a stored procedure (SI_PowerBI_TalentPool), but it requires a @customerid parameter that isn't being passed correctly. When you input the customer ID manually, it works fine, but when you try to make it dynamic (likely using a parameter or slicer), it doesn't function as expected.

How to Fix It
Here are a few suggestions you can try:

1. Properly Define the Parameter in Power Query
Open the Power Query Editor in Power BI.
Navigate to Manage Parameters → New Parameter.
Name it customerid, and set its type to Text or Number (depending on what your SQL procedure requires).
Assign a default value (just for testing purposes).
2. Adjust the SQL Query to Incorporate the Parameter
If you're writing the query directly in Power BI, you might have something like:

sql

EXEC SI_PowerBI_TalentPool @customerid = '12345'
Instead, modify it to:

sql

EXEC SI_PowerBI_TalentPool @customerid = @customerid.

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.