cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Advocate II
Advocate II

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

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
Community Support

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.

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.

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
Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (76,212)