cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sdowse
Resolver I
Resolver I

Not equals function with a nested substring function seems to reverse the outputs

Hi All

 

My head is hurting!! I noticed an expression I built into a flow was doing the opposite of what I thought it should do - so I did some testing by running the two expressions shown below - as far as I can work out the substring function should return "7" (and it does when I tried it separately), so therefore both expressions are the same - BUT they each provide a different answer!

 

if(not(equals(7,7)),'Home','Mobile') this returns "Mobile" (which I think is correct as the not equals returns false)

 

if(not(equals(substring('07568855',1,1),7)),'Home','Mobile') this returns "Home" (which I think is wrong because the not equals should be returning false)

 

My testing just involved me putting the two expressions into separate Compose actions.

 

Does anyone have any ideas what I might be doing wrong?

 

Thanks!

 

Simon

1 ACCEPTED SOLUTION

Accepted Solutions
efialttes
Super User III
Super User III

Hi!

I would try with

 

int(substring('07568855',1,1))

 

I mean, substring returns a string output, you need to convert it into integer again

 

So the overall expression should look like:

if(not(equals(int(substring('07568855',1,1)),7)),'Home','Mobile') 

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

3 REPLIES 3
efialttes
Super User III
Super User III

Hi!

I would try with

 

int(substring('07568855',1,1))

 

I mean, substring returns a string output, you need to convert it into integer again

 

So the overall expression should look like:

if(not(equals(int(substring('07568855',1,1)),7)),'Home','Mobile') 

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

Thanks so much @efialttes, that put me on the right track! I did cheat slightly by using quotes around the 7 to make it a string, rather than making the output of the substring an integer, but it works!

 

if(not(equals(substring('07568855',1,1),'7')),'Home','Mobile')

Thanx for your kindness, and happy flowing!



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MSFTBizAppsLaunchEvent

Experience what’s next for Power Virtual Agents

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Users online (18,500)