Power Automate doesn't seem to compare strings using the same rules that most programming languages do.
I ran into this problem when working with orderHints for checklists in Planner tasks. I'm re-creating a task from a template, and I need all of the checklists to be in order.
Planner gives me the info I need to reconstruct the order using orderHints. Order hints are meant to be sorted based on the ordinal values of the characters in the string. This sounds complex, but it's actually the way many programming languages (like Python and JavaScript) compare strings by default.
The issue is that Power Automate usually seems to follow this method when comparing strings, but not always.
Here's an example. I need to compare two orderHints. One is '858558816[?', and the other is '858558816=2'. If I compare them in Python, it correctly identifies that the first value is greater.
print('858558816[?' > '858558816=2')
Running that will return True.
If I make the same comparison in Power Automate, however:
It returns False:
Like I said, most of the time Power Automate is comparing strings the way I would expect. But it is wrong often enough that it's useless for using orderHints, and I imagine for a wide variety of other string comparison tasks.
Does anyone know a reason for this behavior? Is Power Automate using a completely different comparison method? Is there any way to get it to compare using ordinals, like other languages?
hi @Jronash greater expression only compare numbers so Int type of value, so you are using and string and that's why is not working.
Proud to be a Flownaut!
Hi @ChristianAbata. According to Microsoft's documentation, greater() can compare integers, floats or strings.
You can try it for yourself - if you pass greater() two strings to compare, it will give you a result.