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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. 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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.