cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
sp_mike Regular Visitor
Regular Visitor

Run stored procedure in a loop

I get some data from a table, let say salesorders. 

Each salesorder has a few orderlines, to get the details from the orderlines I need to run a stored procedure for each line.

I know how to run the stored procedure, allthough not in direct query (which is still not possible?) but I can work around that. But how can I run the stored procedure a few times (for each....)?

 

Thanks, Mike

1 ACCEPTED SOLUTION

Accepted Solutions
sp_mike Regular Visitor
Regular Visitor

Re: Run stored procedure in a loop

Thanks, I also found this solution https://www.youtube.com/watch?v=iiNDq2VrZPY 

In my case this is a better solution. However I notice something strange. Looks like the data which is in all the "data tables" is not loaded. Seems like I first need to open a table before the data gets loaded. Still try to figure this out.

View solution in original post

3 REPLIES 3
Community Support Team
Community Support Team

Re: Run stored procedure in a loop

Hi sp_mike,

In your scenario, you said that you want to run stored peocedure in a loop, did you mean that you want to get multiple records at a time instead of getting one record at each time, right? If so, you could try to modify you stored procedure , then pass multiple parameters like "p1,p2,p3" in powerbi , then you should get records of p1,p2p3  from stored procedure.

You could refer to How to pass multi-value parameters to a Stored Procedure datasource for details.

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

sp_mike Regular Visitor
Regular Visitor

Re: Run stored procedure in a loop

Thanks, I also found this solution https://www.youtube.com/watch?v=iiNDq2VrZPY 

In my case this is a better solution. However I notice something strange. Looks like the data which is in all the "data tables" is not loaded. Seems like I first need to open a table before the data gets loaded. Still try to figure this out.

View solution in original post

sp_mike Regular Visitor
Regular Visitor

Re: Run stored procedure in a loop

Got it, I forgot to select the columns from the Stored pocedure (as explained in the video).

Helpful resources

Announcements
October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 223 members 2,158 guests
Please welcome our newest community members: