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
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.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

Users online (1,231)