cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
McMonty
Resolver I
Resolver I

Multiple Choice data from Microsoft Forms

Hi,

I have a SharePoint list with data from a Microsoft Forms survey. One of the fields is a multiple choice field where the data looks like this:
["Option 1","Option 2","Option 3"]

 

I'm not sure if this is an array, but I'm trying to turn the above into the string below:

Option 1; Option 2; Option 3

 

Any idea how this could be done?

2 ACCEPTED SOLUTIONS

Accepted Solutions

Hi @McMonty,

 

The output of the Choice type answer for MS Form will be string, so the only way to process the string to you want is some part of @Jay-Encodian's method 1.

 

You can add the replace function in the right Expression Bar:

Annotation 2019-12-02 170039.png

 

 

You can try this expression, the variables('Choice') is the output of your Choice answer:

replace(replace(replace(replace(variables('Choice'),'[',''),']',''),',',';'),'"','')

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Hey@v-litu-msft @McMonty 

To parse the string to an array use the JSON expression:

a.png

Expression: json(<formVariable>)

a.png

Super simple 🙂

HTH

Jay

View solution in original post

11 REPLIES 11
Jay-Encodian
Community Champion
Community Champion

Hey @McMonty 

The following solution works albeit it it way more complex than I'd like!

1.png

 1. Create an array of chars which need to be removed from the string: createArray('[',']','"')

1.png

 2. Add a variable to store the 'Initial value' I've manually set the value...

1.png

 3. Add a new variable to store the changing / new value

1.png

4. Add an 'Apply to each loop'

5. Set the 'Output from previous steps' to the array variable created in step #1

6. Add a 'Set Variable action', add the following expression: replace(variables('InitialValue'),item(),'')

1.png

 7. Add a 'Set Variable action' to copy the NewValue to the InitialValue variable... you can't self reference in the replace expression 😞

1.png8. Finally... Add a another 'Set Variable' action underneath the 'Apply to each' loop to perform the final replace expression: replace(variables('InitialValue'),',','; ')

1.png

 Your Flow config should look like this... a little convoluted but it works!:

1.png

HTH

Jay

-------------------------------------------------------------------------

If I have answered your question, please mark your post as Solved.

If you like my response, please give it a Thumbs Up.

 

Hey @McMonty 

So this was really bugging me yesterday... I thought there must be an easier way! and there is!

I forgot about the 'Join' action... much simpler:

a.png

 

a.png

 

A little bit simpler!

HTH

Jay

-------------------------------------------------------------------------

If I have answered your question, please mark your post as Solved.

If you like my response, please give it a Thumbs Up.

Hi, my only question is where in the previous solution do I add / replace this?

Hi @McMonty 

The second post totally replaces the the first post... they are both complete answers that do the same thing in a different way.

The second post is obviously a lot simpler...

All you really need is the 'Join' action passing in your Form data... that's it 🙂

HTH

Jay

-------------------------------------------------------------------------

If I have answered your question, please mark your post as Solved.

If you like my response, please give it a Thumbs Up.

 

Hi @McMonty,

 

The output of the Choice type answer for MS Form will be string, so the only way to process the string to you want is some part of @Jay-Encodian's method 1.

 

You can add the replace function in the right Expression Bar:

Annotation 2019-12-02 170039.png

 

 

You can try this expression, the variables('Choice') is the output of your Choice answer:

replace(replace(replace(replace(variables('Choice'),'[',''),']',''),',',';'),'"','')

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hey@v-litu-msft @McMonty 

To parse the string to an array use the JSON expression:

a.png

Expression: json(<formVariable>)

a.png

Super simple 🙂

HTH

Jay

McMonty
Resolver I
Resolver I

Hi all,

 

Big thanks to you both!

 

I created a variable containing the data from the multiple choice field and then used replace to get the string I wanted when creating the SharePoint item.

replace(replace(replace(replace(variables('Choice'),'[',''),']',''),',',';'),'"','')

You learn something new everyday 🙂

You learn something new every day 🙂

 

DanielS19
Frequent Visitor

Hello Everone!

Thank you for solved !

Is it possible to skip lines for each string received from this solution?

lbernstein
Regular Visitor

How would you format the Body if you wanted the output to be the following?

 

Option 1

Option 2

Option 3

You can use the following expression in a Compose function: join(outputs('ConvertResponseToJSON'),'<br>')

Jason3675_0-1642811526740.png

 

Harsh18
Frequent Visitor

Hello,

 

See below trick to using simply multiple choice answer and get row wise answers.

 

using join with <br> tag

json(outputs('Get_response_details'))

<br>

 

Harsh18_0-1657598255327.png

 

Harsh18_1-1657598495624.png

see the results..

 

Harsh18_2-1657598607253.png

 

Hope you like it.

 

Thanks,

Harsh

 

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.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (4,182)