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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
the606
Helper I
Helper I

Passing a parameter to a query in Power Query for a SQL stored proc

Hi,

 

I need to pass a parameter to be sent to a stored proc in SQL. I have created a parameter on an excel sheet looking at a field called date_parameter. This is showing up as a parameter in power query, the @asatdate  works if i put in a date instead of the parameter (example = Sql.Database("IP_Address", "DB_NAME", [Query="execute UDEF_BI_DEF_AGED_DEBTORS_EXTENDED @ASATDATE = '06/08/2021'"])

 

I have tried various mmethods of passing this across and i cant seem to get the styntax correct.

 

Any ideas?

 

= Sql.Database("IP_Address", "DB_NAME", [Query="execute UDEF_BI_DEF_AGED_DEBTORS_EXTENDED @ASATDATE = Parameter[Date_Parameter]{0}"])

 

This is my latest try!

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi  @the606 ,

 

You can create a custom function in power query then use it as parameter to execute a Stored Procedure.

Check the reference below:

 https://docs.microsoft.com/en-us/power-query/custom-function

 

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

View solution in original post

2 REPLIES 2
v-kelly-msft
Community Support
Community Support

Hi  @the606 ,

 

You can create a custom function in power query then use it as parameter to execute a Stored Procedure.

Check the reference below:

 https://docs.microsoft.com/en-us/power-query/custom-function

 

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

CNENFRNL
Community Champion
Community Champion

Value.NativeQuery comes to your rescue,

https://blog.crossjoin.co.uk/2016/12/11/passing-parameters-to-sql-queries-with-value-nativequery-in-...


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors