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

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Append to Array only if condition is met

(0) ShareShare
ReportReport
Posted on by 6

Hello, is it possible to make an Append to Array Variable conditional? For example I would only like their email appended to the variable only if they have 'District' selected on the source list.

 

enunez1998_0-1698350424875.png

 

enunez1998_1-1698350428698.png

 

 

I have the same question (0)
  • JonDoesFlow Profile Picture
    1,304 on at
    Re: Append to Array only if condition is met

    Yeah create a condition which contains District and then do what you need to do if true ?

  • enunez1998 Profile Picture
    6 on at
    Re: Append to Array only if condition is met

    Sorry should've been more specific in asking my question. Where exactly in the flow should I add the condition? 

     

    I tried adding in the condition right after the Apply To Each and it errors out each time. Also to note when I added in the condition to look at Building Value it automatically added another Apply To Each.

     

    Error: The execution of template action 'Apply_to_each_2' failed: the result of the evaluation of 'foreach' expression '@items('Apply_to_each')' is of type 'Object'. The result must be a valid array

     

    enunez1998_0-1698352401628.png

     

  • Verified answer
    grantjenkins Profile Picture
    11,059 Moderator on at
    Re: Append to Array only if condition is met

    The easiest way is to use the Filter Query within your Get items so it only brings back items where the Building is equal to District.

     

    For this example, I have the following list. Note that I've just renamed the Title field to Email which looks the same as what you have done.

    grantjenkins_0-1698563553235.png

     

    Below is the full flow. I'll go into each of the actions.

    grantjenkins_1-1698563616024.png

     

    Get items retrieves the items where the Building is equal to District. This will work even for a multi-select Choice field.

    Building eq 'District'

    grantjenkins_2-1698563680903.png

     

    Select retrieves just the Emails (Title field) into a simple array.

    grantjenkins_3-1698563738512.png

     

    Join uses the output from the Select and joins the emails with a semi-colon ;

    grantjenkins_5-1698563815318.png

     

    If we ran the flow now we would get the following output.

    grantjenkins_6-1698563873838.png

     

    You can then use the output from the Join in your Send an email notification 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 659 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 386 Moderator

#3
chiaraalina Profile Picture

chiaraalina 290

Last 30 days Overall leaderboard