cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
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

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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.

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

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020

thirdimage

Flow 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 Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 158 members 4,351 guests
Please welcome our newest community members: