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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
AnanthanR
Helper I
Helper I

How to use Stored procedure with parameter in Power bi

I have SP with parameter in sql server. I tried to call (use) this in Power bi desktop but I am getting error. like incorrect syntax.

 

AnanthanR_0-1690346229662.png

I am getting below error.

AnanthanR_1-1690346302950.png

any help It would be helpfull for me.

 

Thanks,

Ananth

 

1 ACCEPTED SOLUTION

Hi Tom,

 

After closing the error window, in Advanced editor i added the below code. Its working fine.

 

let
Source = Sql.Database("Servername", "AdventureWorksDW2019", [Query="SELECT * FROM OPENROWSET('SQLNCLI','server=Servername;trusted_connection=yes;','EXEC AdventureWorksDW2019.dbo.GetSalesDetails @Category=" & Category & "')" ])
in
Source

 

Thank you.

 

Ananth

View solution in original post

7 REPLIES 7
TomMartens
Super User
Super User

Hey @AnanthanR ,

 

hopefully, this video will get you started: https://www.youtube.com/watch?v=N1En6_NB_dY

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi TomMartens,

 

Thanks for your time.

The same vedio i checked and followed the steps, but its not working getting error like, incorrect syntax.

 

Thanks,

Ananth

Hey @AnanthanR ,

without providing the exact source code it's difficult to spot anything unexpected.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi TomMartens,

 

I am getting error in first step itself. i entered server and DB details and i tried to use SP with Parameter.  getting Incorrect syntox error.

 

i ran below script in sql server. based on the suggestion provided in the vedio. but still not working.

 

EXEC
sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
EXEC
sp_configure 'Ad Hoc Distributed Queries', 1
RECONFIGURE
GO

 

Thanks.

Ananthan

Hey @AnanthanR ,

having the error is "expected"

Make sure that you follow the steps from the video and edit the query inside Power Query after you have the closed the error dialog you shared initailly. The query needs to start with SELECT, this is the reason why you need the OPENROWSET.

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Thanks TomMartens,

 

I will change the query and try.

 

Thanks,

Ananth

Hi Tom,

 

After closing the error window, in Advanced editor i added the below code. Its working fine.

 

let
Source = Sql.Database("Servername", "AdventureWorksDW2019", [Query="SELECT * FROM OPENROWSET('SQLNCLI','server=Servername;trusted_connection=yes;','EXEC AdventureWorksDW2019.dbo.GetSalesDetails @Category=" & Category & "')" ])
in
Source

 

Thank you.

 

Ananth

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors