cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
980Panama
Level: Powered On

SQL Server Transform Data using Power Query

I am having a problem using the Flow connector SQL Server Transform Data using Power Query.  I am getting the error message 

 
ExpressionEvaluationFailed. The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@body('Transform_data_using_Power_Query')' is of type 'Object'. The result must be a valid array.
 
I cannot choose Value as an output it returns an output of Body instead.  This is a great connector and I have many applications for it if I could only get it to work.  This is being used on Sql Server database.  I have enabled Load within the query.  I am using a simple table just to get it to work first.
 
the Outputs are shown below:

Flow.PNG
 
 
 
 
 
 
 
 
 
 

Flow2.PNG

 
 
 
 
 
 
And here is the flow:
 

Flow3.PNG

 
 
 
 
 
 
 
 
 
and the query:
 

Flow4.PNG

 
 
 
 
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
980Panama
Level: Powered On

Re: SQL Server Transform Data using Power Query

Ok I have found my own solution and will share it here as I did find it a bit complex.

 

The output type from my Power Query is body (other examples have value so I think this is a bug).

 

I take the output from the connector 'Transform data using Power Query' - 'body' and feed this into Parse JSON action in the Content line.  It then asks you to add a schema.  at the bottom of the screen is a hyperlink which you need to press "Use sample payload to generate schema" - it will come up with a blank screen for you to enter data - I went off to a failed run and copied just the value portion of the output from the Power query which contains the fields I need in the array output.  I then pasted this data into the blank screen and clicked update.  This then generates a nice clean version of your data into a proper schema.

 

In the next action Apply to each you can now use the output from the Parse JSON action which is now called value - i show the example Parse Json below. Hope this is useful.

Pase JSON.PNG

 

 

 

 

 

 

 

 

 

 

 

Pase JSON2.PNG

 

 

 

 

 

 

Pase JSON3.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

View solution in original post

3 REPLIES 3
Community Support Team
Community Support Team

Re: SQL Server Transform Data using Power Query

Hi @980Panama,

 

In the Apply to each, can you select Value from the previous action Transform data using Power query?

Please try to use function items to return the current item from each cycle in a for-each loop. More details for your reference:

https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#i...

Besides, here are the blogs about Power query online for Microsoft Flow, please check the following links for a reference:

https://flow.microsoft.com/en-us/blog/powerquery-flow/

https://blog.crossjoin.co.uk/2018/09/26/using-power-query-and-microsoft-flow-to-automate-the-creatio...

 

Best regards,

Mabel

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
980Panama
Level: Powered On

Re: SQL Server Transform Data using Power Query

Thank you Mabel it is very helpful to have all these links together, I have already read all these and still cannot find the answer to the issue.  In answer to your question I cannot select Value from dynamic content in the Apply to Each (only body is available).  I dont know how to use the current item in dynamic content is this something I could use instead.  Can you explain how I would use a function to make the Body output usable such as Value.

 

Before going down this route though I am thinking there must be something wrong with my flow as all other examples I have seen in the documentation have a Value dynamic output available and I do not. Appreciate any insights I am just so keen to get this working.

Highlighted
980Panama
Level: Powered On

Re: SQL Server Transform Data using Power Query

Ok I have found my own solution and will share it here as I did find it a bit complex.

 

The output type from my Power Query is body (other examples have value so I think this is a bug).

 

I take the output from the connector 'Transform data using Power Query' - 'body' and feed this into Parse JSON action in the Content line.  It then asks you to add a schema.  at the bottom of the screen is a hyperlink which you need to press "Use sample payload to generate schema" - it will come up with a blank screen for you to enter data - I went off to a failed run and copied just the value portion of the output from the Power query which contains the fields I need in the array output.  I then pasted this data into the blank screen and clicked update.  This then generates a nice clean version of your data into a proper schema.

 

In the next action Apply to each you can now use the output from the Parse JSON action which is now called value - i show the example Parse Json below. Hope this is useful.

Pase JSON.PNG

 

 

 

 

 

 

 

 

 

 

 

Pase JSON2.PNG

 

 

 

 

 

 

Pase JSON3.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

View solution in original post

Helpful resources

Announcements
firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors
Users online (4,479)