How to Fix Power Automate Apply to Each Array Error in Microsoft Forms
Question details
The user is unable to pass an array variable to the 'Apply to each' action in Power Automate when building a flow to automatically grade text answers.

- Product
- Microsoft Power Automate / Microsoft Forms
- Device & OS
- not provided
- Scenario
- Automating the assessment of Microsoft Forms written responses by detecting specific keywords, assigning marks, and flagging answers based on the text.
- Observed behavior
- The 'Apply to each' action rejects the provided variable, indicating that it is not receiving a valid array structure from the Forms response or previous steps.
Ensure you have access to edit your Power Automate flow and can run a test submission from your Microsoft Form to view the raw JSON outputs of your workflow.
Verify Variable Type and Array Initialization
Ensure that the variable passed to the 'Apply to each' action is explicitly formatted and recognized as an array.
Power Automate requires a strictly defined array format (a list of items) for loops to function. When extracting data from Microsoft Forms, the output is often a single text string rather than an array, which causes the 'Apply to each' action to fail.
In your flow design, locate the 'Initialize variable' action where you define your keywords or responses. Ensure the 'Type' dropdown is set strictly to 'Array'.
If you are extracting multiple answers from Forms, use a 'Parse JSON' action. Check the JSON schema to ensure the specific output field is defined as an array type.
If your Microsoft Forms response returns a single string separated by commas, click on the 'Apply to each' input box, navigate to the Expression tab, and use the split function: split(variables('YourVariable'), ',') to convert the string into a valid array.
Try WPS Office for Efficient Form Data Processing
While Power Automate handles automated workflows, managing, analyzing, and formatting your collected form data is much easier with WPS Office. As a lightweight and free alternative to Microsoft Office, WPS Spreadsheet offers powerful data analysis tools that are fully compatible with Excel formats.
- 1. Export your form responses: Download your Microsoft Forms assessment responses as an Excel (.xlsx) or CSV file.
- 2. Open the data in WPS Spreadsheet: Launch WPS Office and open the exported file to view all written responses in a clear, structured grid.
- 3. Analyze and grade keywords: Use WPS Spreadsheet formulas or the Find feature to quickly detect keywords, calculate grades, and flag alternative answers directly in your workbook.

Frequently Asked Questions
Why does Power Automate say my variable is not an array?
This usually happens if the data extracted from Microsoft Forms is passed as a plain text string instead of a structured array format. You must convert the string into an array using the split() function or a 'Parse JSON' action before using it in a loop.
Can I use Power Automate to grade long text answers in Microsoft Forms?
Yes, you can extract the text from the form submission and use an 'Apply to each' loop alongside conditional actions (like 'contains') to search for specific keywords and assign points based on those matches.
How do I manually format an array for keywords in Power Automate?
To format an array manually, initialize an Array variable and format your values enclosed in square brackets, separated by double quotes and commas, for example: ["keyword1", "keyword2", "keyword3"].




