How to use number from MS Forms in a Power Automate condition
Posted On November 7, 2021
“I’d like to send different notification for good and bad rating via MS Forms form, but my Power Automate condition to check the number doesn’t work.
“The template language function ‘greater’ expects two parameter of matching types. The function was invoked with values of type ‘String’ and ‘Integer’ that do not match.
If you use Microsoft Forms to collect feedback, you might collect also some kind of rating. It can be a star rating, number rating, or just a text field to type in a number. The flow can then behave differently depending on this rating. It can send a notification if there’s a bad rating for immediate feedback, or reply with a ‘thank you’ message for a good one. It could also store the response in a SharePoint list to keep track of the bad reviews. But no matter what the flow does, you must always use a ‘Condition’ to evaluate the rating. And that’s where you might encounter a problem if you use the ‘less’ or ‘greater’ condition.
Convert the values
As the error message will tell you, you’re trying to compare a string with an integer. A text with a number. The ‘Condition’ needs both of the sides with the same type. You need either 2 strings or 2 integers, but you can’t combine them (the exception being ‘is equal to’ condition).
As it must be 2 strings or 2 integers, you’ve got two options how to change the type. You can use the string(…) or int(…) expression to change the left or the right side of the condition, e.g.
int(Rating) <operator> number
Rating <operator> string(number)
Warning: don’t try to convert the number to string using single quotes, e.g. ‘3’. Such condition won’t work properly.
All the information Power Automate will extract from MS Forms will be provided as a string, and as such it won’t work in a condition with a number. Such condition will end with an error, unless you convert one of the sides to the right format. And it’s up to you if you want to convert the left or the right side (but the right side is easier).