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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Taking corresponding a...
Power Automate
Answered

Taking corresponding actions according to what contains in a string array

(0) ShareShare
ReportReport
Posted on by 6

Let's say I have a MS form, Q1 has choices such as apple, orange, lemon, and allow multiple selection

Q2 has choices such as lettuce, tomato, potato, and allow multiple selection.

 

Different items cost differently, and I want to calculate the total amount that the responder needs to pay according to his selection.

 

I think I have successfully appended the answer from different questions to one single array variable, contains all the strings from the answer.

 

And I find that "Switch" action can only process string but not array, and I don't know how to perform the logic of 
"if the array contains apple, add $2"; "if the array contains potato, add $4"; "if the array contains tomato, add $5"

 

Moreover, sorry that I have not yet searched for anything about automatically sending email in power automate. Is it easy if I want to sent back this amount to be paid & the items that he has chosen back to responder's email?

Categories:
I have the same question (0)
  • v-yetonggu-msft Profile Picture
    Microsoft Employee on at

    Hi @Levinand ,

    Could you please show me a screenshot of your existing flow configuration?

     

    Best Regards,

    Sunshine Gu

  • Levinand Profile Picture
    6 on at

    Levinand_0-1714704345160.png

    Forget the excel thing in the middle, that is not mentioned

     

    I try to use filter array in the second parallel operation in order to perform corresponding actions according to array, and fails.

    And the flow for sending email is not yet started

  • Verified answer
    v-yetonggu-msft Profile Picture
    Microsoft Employee on at

    Hi @Levinand ,

    To be honest, I don’t know what you are doing based on the flow screenshot you provided, but based on your demand description, I built a test myself for your reference.

    My MS Form:

    vyetonggumsft_2-1714708658318.png

    My Flow Overall Preview:

    vyetonggumsft_2-1714707299582.png

    My Flow parameters configuration:

    vyetonggumsft_0-1714708227251.png

    The function of the above four 'initialize variables' and 'append to array variable' controls is to add the options selected in the two multiple-choice questions to an array variable.
    It is convenient for looping in 'apply to each' later.

     

    json()

     

    vyetonggumsft_4-1714707707518.png

     

    Explain the meaning of this code. If the option you choose contains apple+2, if the option you choose contains orange+3, if the option you choose contains lemon+4, and so on, finally break out of the loop and get the total price.

    if(contains(items('Apply_to_each_3'),'apple'),2,
    if(contains(items('Apply_to_each_3'),'orange'),3,
    if(contains(items('Apply_to_each_3'),'lemon'),4,
    if(contains(items('Apply_to_each_3'),'lettuce'),5,
    if(contains(items('Apply_to_each_3'),'tomato'),4,5)))))

     

    Best Regards,

    Sunshine Gu

  • Levinand Profile Picture
    6 on at

    Thanks for your advice. Actually my flow is similar, and my only concern is that the total number of items may up to 10 - 20, and the 'if' part can by very long.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 873

#2
Valantis Profile Picture

Valantis 813

#3
Haque Profile Picture

Haque 526

Last 30 days Overall leaderboard