Skip to main content

Notifications

Power Automate - General Discussion
Answered

Need Help with Comparing Microsoft Forms Responses to JSON Array (key value)

(0) ShareShare
ReportReport
Posted on by 7
Hello, I need some help. 
 
My flow starts with the Trigger "When a new response is submitted", because I'm using Microsoft Forms. After that, it has an action called "Get response items". 
 
Then I Initialize a variable called "pregunta" (a string) that saves an answer from the Forms.

 

Captura de pantalla 2023-10-16 163411.png

The thing is, this answer can be 6 options, Option A to Option F (these are just examples, names are in Spanish). 
Each Option is assigned to a number, so: Option A = 1, Option B = 2, Option C = 3, and so on. 
 
(variable "numeroPregunta is 10, just because, to initialize it) 
 
Captura de pantalla 2023-10-16 163826.png

Chat GPT gave me this code for the Compose Action. 

if(equals(variables('pregunta'),variables('jsonPreguntas').jsonPregunta),variables('jsonPreguntas').jsonNumeroPregunta)

 

But it's not working.

 

Do you know how I can do this? 


Variable = "Cat" 


[

{"pet": "dog",

"color": "black"},

{"pet": "cat",

"color": "orange"},

"pet": "mouse",

"color": "white"}

]

 

new Variable = orange

I need to obtain the other parameters that match with my variable. 

Maybe I'm not using the json array correctly or something. 

Please, I would appreciate your help! 

  • javieracortes04 Profile Picture
    javieracortes04 7 on at
    Re: Need Help with Comparing Microsoft Forms Responses to JSON Array (key value)

    It did work! 

    Thank you so much! 

  • Verified answer
    Chriddle Profile Picture
    Chriddle 7,336 on at
    Re: Need Help with Comparing Microsoft Forms Responses to JSON Array (key value)

    These transformations can bedone with simple objects.

     

    Here an example flow where the trigger input is transformed to the according number:

    Chriddle_1-1697641117167.png

    "Test" Input:

    outputs('Transformation')[triggerBody()['text']]

     

     

    The flow run looks like this:

    Chriddle_0-1697641040002.png

     

  • javieracortes04 Profile Picture
    javieracortes04 7 on at
    Re: Need Help with Comparing Microsoft Forms Responses to JSON Array (key value)

    First of all, thank you. 

    But I think I didn't explain myself so well. So sorry! 

     

    I need to "transform" the answer to an equivalent index. If the answer was Cat, then I need the variable set to 1. If the answer is Dog then variable = 2, and so on. 

     

    I need to do this with 2 questions, the first one has 6 options, but the second one has 41 options, so I hope the answer to my problem is not booleans or parallel branches.  


    image.png

     

    Best regards, 

    Javiera

  • Re: Need Help with Comparing Microsoft Forms Responses to JSON Array (key value)

    Hi @javieracortes04 ,

     

    I've made a test for your reference:

    1\The Form

    vbofengmsft_1-1697506085417.png

    2\My flow

    vbofengmsft_0-1697506001897.png

    3\Result

    vbofengmsft_2-1697506140035.png

     

    Best Regards,

    Bof

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,508

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,839

Leaderboard