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 / Converting Form Respon...
Power Automate
Unanswered

Converting Form Responses to Numeric Values

(0) ShareShare
ReportReport
Posted on by 2

I am currently working on a flow that takes in responses from a Microsoft Form. In this flow, I am trying to convert certain responses in the questions of the form to a numeric value and then calculate the value of all the responses.

 

For example:
What is your favorite Nintendo character?
a. Mario
b. Link
c. Kirby

If they answered Mario, the score for that question would be 7.5. If they answered Link, it would be 5.5. If they answered Kirby, it would be 3.5.


After the steps where I get the form responses, I have an "Initialize variable TotalValue" set to:
Name: TotalValue
Type: Integer
Value: 0

 

Then I have an "Apply to each" action with an output of "triggerBody()?['body']"


In the Apply to each, I have a Switch action titled "Nintendo Characters" with "On" set to "items('Apply_to_each')['What is your favorite Nintendo character']"

There are 3 cases in the Switch: Mario, Link, and Kirby. Each one has a Compose action with these inputs:
Mario
Equals: Mario
Compose: Inputs: 

add(variables('TotalValue'), 7.5)
 

Link
Equals: Link
Compose: Inputs: 

add(variables('TotalValue'), 5.5)
 

Kirby
Equals: Kirby
Compose: Inputs: 

add(variables('TotalValue'), 3.5)
 
There are 3 other Switch actions that are created similarly (different content but same idea with the Compose actions inside the Cases) and all reside inside the "Apply to each" action.
 
When I fill out the form, it fails, and I can see this when I look at the Run details:


Error Details:

The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@triggerBody()?['body']' is of type 'Null'. The result must be a valid array.

 

I have tried having the "Apply to each" action have an output of "triggerOutputs()?['body']" however the flow still fails and I get this:

 

Error Details:

The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@triggerOutputs()?['body']' is of type 'Object'. The result must be a valid array.

 

Any help would be greatly appreciated.

Categories:
I have the same question (0)
  • creativeopinion Profile Picture
    10,502 Super User 2025 Season 2 on at

    @dheston You. might be interested in a tutorial I recently uploaded: How to Get a Microsoft Form RSVP Response into a SharePoint List

     

    I demonstrate  how to take a text response and convert it to a number with a switch action and with an expression in this section.

     

    I also cover the following in this video tutorial:

    ✅ How to get a Microsoft Form Response into SharePoint

    ✅ How to get a Microsoft Form ID

    ✅ How to get a Microsoft Form response

    ✅ How to Build a Microsoft Form with Conditional Fields

    ✅ How to used Branching in Microsoft Forms

    ✅ How to format Microsoft Form multiple choice responses for a SharePoint multi-choice column

    ✅ How to parse a Microsoft Form multiple choice response as string of text

    ✅ How to convert a text response to a number

    ✅ How to use the Switch action

    ✅ How to create a custom email confirmation for a Microsoft Form submission

    ✅ How to Create a Custom View in a SharePoint list

    ✅ How to use the Compose Action

    ✅ How to write Power Automate Expressions

     

    Hope this helps!


    If I helped you solve your problem—please mark my post as a solution ✅.
    Consider giving me a 👍 if you liked my response!

    👉 Watch my tutorials on YouTube
    👉 Tips and Tricks on TikTok

  • dheston Profile Picture
    2 on at

    I will take a look! Thank you!

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 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard