cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RuthJennaway
Regular Visitor

Problems with Expression to convert Forms text answer to a number

Hi,

I am using Power Automate to copy Form responses to a SharePoint list

The problem I have is I need to to total up the answers, so 'Not al all' = 0 for example.

Should be easy, but I have got stuck with a problem with using an Expression to convert Forms answer to a number.

 

if(equals(<form field here>,'Not at all'),'0','error')
 
In fact with the forms choice is a Likert option, but I can easily get the text into an email or SharePoint list, so I am not sure why this is not working
This the with the forms data field in:
if(equals(outputs('Get_response_details')?['body/r020e7d0656574b7185a94dc9bab4d106'],'Not at all'),'0','error')
 
Any idea at all what obvious thing I am missing??
Thanks 
Ruth
 
5 REPLIES 5
ManishJain
Solution Sage
Solution Sage

Hi @RuthJennaway ,

 

What is the error you are getting while doing this ? 

 

Thanks

Hi @ManishJain 

thanks for your reply, I should have said.

There was Error in Power Automate, it runs successfully, just always resolves to whatever value in put in the else clause. So I am trying to work out what is logically wrong with the If statement

 

So 

if(equals(<form field here>,'Not at all'),'0','error')   results in error being written to the SharePoint field

 or 

if(equals(<form field here>,'Not at all'),'0','999')  results in 999 being written to the SharePoint field

 

The thing is a similar Form I did previously worked OK with these types of if statement, so I am at a loss!

Regards

Ruth

Paulie78
Super User
Super User

I would put a compose action before your if expression which just contains:

outputs('Get_response_details')?['body/r020e7d0656574b7185a94dc9bab4d106']

To determine what the value of it is, to see if it does actually match "Not at all" at the time of execution.

RuthJennaway
Regular Visitor

Hi ManishJain, thanks for your reply, I should have said the following :

No Error in Power Automate, it runs fine, just always resolves to whatever value in put in the else clause.

 

So 

if(equals(*form field here*,'Not at all'),'0','error')

results in error being written to the SharePoint field

or

if(equals(*form field here*,'Not at all'),'0','999')

results in 999 being written to the SharePoint field

 

The thing is a similar Form I did previously worked OK with these types of if statement, so I am at a loss!

Regards

Ruth

RuthJennaway
Regular Visitor

OK.
The solution was simple after all.
Copy and paste from other Power Automate If statements occasionally inserts non-standard space characters into the formula.

So once I had retyped every text comparison by hand it worked fine.
Grrr.
OK, now I know!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Users online (2,700)