web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / "Apply to each" error ...
Power Automate
Unanswered

"Apply to each" error – says invalid expression, but array from Compose is valid

(0) ShareShare
ReportReport
Posted on by 932 Super User 2024 Season 1
Hi All,

I’ve created a Power Automate flow that’s meant to extract tasks from Microsoft Planner and update an Excel file stored in OneDrive for Business. The goal is to make it easier for my manager to track team progress and build Power BI reports on top of that Excel data.
Here’s how the flow is structured so far:

🔧 Flow Outline:
  1. Trigger: Recurrence (runs daily)
  2. List tasks (from a Planner plan)
  3. Get task details for each task
  4. Compose step to extract assigned user IDs:
values(outputs('Get_task_details')?['body/assignments'])
  1. Initialize variable:
    • Name: AssignedNames
    • Type: String
    • Value: (left empty)
  2. Apply to each (loop over Compose output)
  3. Inside the loop:
    • Get user profile (V2) using:

items('Apply_to_each')?['userId']
    • Append to string variable:

outputs('Get_user_profile_(V2)')?['body/displayName'] & "; "
  1. Later steps will insert task details into Excel, including assignee names.

Issue:

I keep getting this error on the Apply to each step:
"The input parameter(s) of operation 'Apply_to_each' contains invalid expression(s)."
Even though the Compose step returns a valid array (I’ve checked this with Peek Code and test outputs), the flow won’t save or run properly.

What I’ve tried:
  • Rebuilt the Apply to each from scratch
  • Used expression:
outputs('Compose')
  • Removed any newlines from expressions (e.g., \r\n)
  • Checked that Compose outputs a proper JSON array of userId objects

Question:

Could the issue be caused by something inside the loop (like the Get user profile step)? Or is there something I’m missing about how Power Automate handles these arrays?
Would appreciate any tips — especially if you’ve run into a similar issue before.
Thanks in advance.
 
Categories:
I have the same question (0)
  • David_MA Profile Picture
    12,966 Super User 2025 Season 2 on at
    Can you show your flow and especially the configuration of the action that generated the error message? You mention an array, but in your flow outline you don't describe an array. Are you referring to the string variable as an array?
     
    You may want to try this instead:
    • Replace the string variable with an array variable and set the default value to []
    • Replace the append to string variable with an append to array variable
    • In the append to array variable, only populate it with the dynamic content you were appending in the string variable and nothing else.
    • Then wherever you need to use the variable, you can use this expression to join the values from the array together as a string: join(variables('AssignedNames'), ', ')
    • You can replace the comma in the above expression with anything you want to join the values with. Based on the error message, you are using an expression somewhere to do this with a semicolon. However, you would do this outside of the apply to each action.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard