I am trying to edit a response in Microsoft Forms before outputting it into an Excel sheet via Power Automate.
I am using the "Compose" action in Power Automate to update the contents of a form response.
I want it to check if the response does not contain a colon. If it does not contain a colon I would like to insert a colon two characters into the response. If it does contain a colon I want it to return the original phrase. This is what I came up with but I can't get it to work. It entirely bypasses the compose action every time.
if(not(contains(triggerBody()?[Question],':')),concat(triggerBody()?[Question],':'),replace(triggerBody()?[Question],':',':'))
The responses will be military time in the following formats. I want to correct the responses to all have the colon separator so that they are instantly compatible with the Excel sheet it will be output to.
1309
14:50
Any guidance would be appreciated 🙂
Hi @alexelise_ ,
It's so strange. I suggest you recreate the flow and switch to the classic designer to avoid unnecessary loops. And you can directly put the output of compose into Add a row into table without filling in the expression again.
I did a test for your reference.
In my scenario:
My Table:
My Flow:
Because the encoding of our Question is different, I don’t recommend you to use my encoding format directly. Please try this expression again.
if(contains(Question,':'),Question,concat(substring(Question,0,2),':',substring(Question,2,2)))
Best Regards,
Sunshine Gu
Hi @v-yetonggu-msft ,
Thank you for your response! I am wondering if you could also help me navigate the next step in my flow as I am assuming adjustments must be made. I also need to add a row to a table in Excel. Now I believe the compose action is working but is just not outputting the edited response in Excel. I have attached pictures of the flow for reference. I know you did not use the "Apply to each" action in your example, but for some reason, Automate will not allow me to have the "Get response details" without auto-applying the action. I tried the flow with only all combinations of the actions being inside the "Apply to each" and got the same results.
I am assuming I need to adjust what is input in the start time box so that it enters the composed answer instead of the exact response collected from the form. But after messing around with my options I am still unable to execute it.
Hi @alexelise_ ,
I did a test for your reference.
In my scenario:
if(contains(Question,':'),Question,concat(substring(Question,0,2),':',substring(Question,2,2)))
The ’Question‘ in the expression represents the Question option in the flow. Replace all ’Question‘ in the expression with the Question option.
Best Regards,
Sunshine Gu