cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JenLavery
Frequent Visitor

Add array values together - output from MS Forms

Hi all, having a real headache with this.  At first, I was pulling the summed up value down from the spreadsheet generated by MS Forms (I added in a calculation column), but flow keeps spitting out that column as a 0 value on the first run (fine if I rerun it) and it's the same no matter what I do.

 

With no other option, I need to make the flow calculate the value and I'm pretty new to coding.  Everything I'm finding on the subject of adding more than two things seems to draw down from a sharepoint list as a data source, which isn't an option in this case.

 

I've created an array from those MS Form values in the Compose function like so:

 

createArray(
outputs('Get_response_details')?['body/r54d2e838f4704b85869d7be3d84c9817'],
outputs('Get_response_details')?['body/ra492c3687e654148a96bd3c5665b4b5e'],
outputs('Get_response_details')?['body/r365199281e074c39825df8766863d86f'],
outputs('Get_response_details')?['body/r64ab68838da84c1095220deea13e9d30'],
outputs('Get_response_details')?['body/ra5241b87c1784045b3f5c8f61e8562f0'])

 

 

I then put in two two 'initialise variables' as float, then an apply to each stage to loop round the values.

JenLavery_0-1620734693692.png

 

 

The first set variable uses the following:

add(items('Apply_to_each'),variable('finalTotal'))

 

The output message I got was that it would only work with an integer or number, so I inserted another Compose function that put an integer around this output as it didn't like it directly, which should have been my first clue it wouldn't work, it said it couldn't be converted to the target type:

 

int(outputs('Array_for_costs'))

 

 

I'm a bit at a loss here.  How can I sum up my 5 array values?  Any insight would be very much appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions

It wasn't an option in this case, as we were using MS Forms rather than the Sharepoint List form.  But I've managed to solve it really inelegantly anyway. 

 

I had to make each individual input an integer, then add together in 4 stages.  Put it in a Scope control for neatness.  😅

View solution in original post

2 REPLIES 2
eliotcole
Super User
Super User

Have you tried making a SharePoint list for the data, and then running the values from the form directly in to that, and then working from there?

It wasn't an option in this case, as we were using MS Forms rather than the Sharepoint List form.  But I've managed to solve it really inelegantly anyway. 

 

I had to make each individual input an integer, then add together in 4 stages.  Put it in a Scope control for neatness.  😅

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022- Season 2 has kicked off!

Users online (2,631)