cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mats_1997
Helper I
Helper I

variable contains string condition doesn't work

Hey

I have a SP list I want to loop over to find the highest value. I've limited the list to only the relevant column, which is formed in a manner like this AB1234, there are some odd values, but I'm fine with those checking false. Meaning I want to find which of the values have the highest 1234 value.

 

The thing is, to filter out the odd values I have to check if the value StartsWith or contains 'AB', when in my condition I check if Temp2 contains 'AB' it never returns true. This puzzles me, since I tried to email the values of temp2 to me, and sure enough it's all my items, of which the huge majority does contain AB. I've tried using startsWith as well, but to no avail. I also tried different ways to write AB, in case it's that I doesn't write it as a proper string. I also tried to firstly just checking the value directly, and I've tried setting the value to a variable temp2. I also tried making temp2 an array, but the value is a string and I found out you can't set an array to a string value...

I'm at a loss for what to do here, why does it not return true when I check if AB1234 contains AB? it completely baffles me.

 

in advance, thanks for all and any reply

 
1 ACCEPTED SOLUTION

Accepted Solutions
abm
Super User
Super User

Hi @Mats_1997 

 

Try ODATA filter substring() function starts with AB, orderby desc and set Count 1. This only works if you  are looking for column values starting with AB and numeric numbers only.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

View solution in original post

6 REPLIES 6
abm
Super User
Super User

Hi @Mats_1997 

 

Try ODATA filter substring() function starts with AB, orderby desc and set Count 1. This only works if you  are looking for column values starting with AB and numeric numbers only.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials
efialttes
Super User
Super User

Hi!

"I have a SP list I want to loop over to find the highest value."

Did you already consider to assign an ODATA expression to 'Order by' input? And assign an ODATA expression to 'Filter Query' input to grab just items containing AB in Temp2 column?

GReat tutorial here

https://sharepains.com/2018/11/12/sharepoint-get-items-odata-filter-query/

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!



@abm 
I'm a tad confused, you mean to set the orderby to descending and count to 1, such that only the highest value will be returned?

 

Hi @Mats_1997 

 

You mentioned "Meaning I want to find which of the values have the highest 1234 value". So if you sort the values by desc and count set to 1 it will always get the highest value. If looking for all the values do not set the count.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

@efialttes 

Hi, The link you sent I think is perhaps outdated? because when I try the OData query that they suggest startsWith(MyField, 'AB') I'm told it's not a valid expression 😞 yes I try to simply put in the name of the field without ' ', if I try to use ' ' it just looks for AB in the string 'MyField', so I'm closer to success but still some ways off, but using OData queries will solve my initial problem

Thank you for sharing your solution! this would help others.

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!

Users online (2,627)