cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jronash
Impactful Individual
Impactful Individual

Power Automate doesn't compare strings properly

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:

compare1.png

It returns False:

compare2.png

 

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?

2 REPLIES 2
ChristianAbata
Super User
Super User

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.



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA

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.  

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (5,910)