cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Elements contained in text

Hi, 

I have an issue where I need some help. My issue is as follows:

1. I have a string variable that contains some text. 

Example: 

Blablabla 12345, 22222

2. Then I have another string that I extracted from an array. 

Example: 

12345, 22222, 98909

 

Aim: 

I want to check whether the elements from no 2 are contained in no 1

Problem: 

There are too many combinations. As an example, I can exact 12345 from no 2 and then find that this is included in no 1. But then I want to know if also 22222 is included in no 1 and also the third element. It might be the case that only 22222 is included in no 1 or 22222 and 98909 but not 12345.

Question:

Is there a smart way to check which of the elments from no 2 are included in no 1?

 

Would be great if somebody could help.

Many thanks in advance.

 

Ludwig 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @lreinhard7 ,

Do you want to check which of the element from no 2 string are included in no 1 string?

 

Based on the needs that you mentioned, I think ForAll function could achieve your needs. I have made a test on my side, please take a try with the following workaround:9.JPG

 

10.JPG

 

11.JPG

 

12.JPG

Set the OnSelect property of the "String1" button to following:

Set(String1, "Blablabla 12345, 22222")

Set the OnSelect property of the "String2" button to following:

Set(String2, "12345, 22222, 98909")

Set the OnSelect property of the "Check Exists" button to following:

Clear(CompareResult);
ForAll(
      Split(String2, ","),
      If(
          Trim(Result) in Trim(Split(String1, ",").Result),
          Collect(CompareResult, {ComparedValue: Result, 'IsExisted?': "TRUE"}),
          Collect(CompareResult, {ComparedValue: Result, 'IsExisted?': "FALSE"})
      )
)

Add a Data Table control, set the Items property to following:

CompareResult

Note: On your side, please replace the String1 variable and String2 variable with your own String variables.

Please consider take a try with above solution, then check if the issue is solved.

 

More details about the ForAll function, please check the following article:

ForAll function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Pstork1
Dual Super User III
Dual Super User III

I would take a look at Match() and IsMatch().  This sounds like the kind of thing that REgex experssions were designed for.  Assuming you can figure out the pattern you are searching for as a REGEX then match or IsMatch will make life much easier and more efficient.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
v-xida-msft
Community Support
Community Support

Hi @lreinhard7 ,

Do you want to check which of the element from no 2 string are included in no 1 string?

 

Based on the needs that you mentioned, I think ForAll function could achieve your needs. I have made a test on my side, please take a try with the following workaround:9.JPG

 

10.JPG

 

11.JPG

 

12.JPG

Set the OnSelect property of the "String1" button to following:

Set(String1, "Blablabla 12345, 22222")

Set the OnSelect property of the "String2" button to following:

Set(String2, "12345, 22222, 98909")

Set the OnSelect property of the "Check Exists" button to following:

Clear(CompareResult);
ForAll(
      Split(String2, ","),
      If(
          Trim(Result) in Trim(Split(String1, ",").Result),
          Collect(CompareResult, {ComparedValue: Result, 'IsExisted?': "TRUE"}),
          Collect(CompareResult, {ComparedValue: Result, 'IsExisted?': "FALSE"})
      )
)

Add a Data Table control, set the Items property to following:

CompareResult

Note: On your side, please replace the String1 variable and String2 variable with your own String variables.

Please consider take a try with above solution, then check if the issue is solved.

 

More details about the ForAll function, please check the following article:

ForAll function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Hi,

Many thanks for this tips. I will try that with PowerApps.

By the way, can the same be achieved in MS Flow?

I created a thread in the Flow forum as this might be an alternative approach for me.

Here is the related link to the flow community thread

https://powerusers.microsoft.com/t5/General-Flow-Discussion/MS-Flow-Elements-contained-in-text/m-p/3...

Many thanks,

Ludwig

Hello Kris Dai,

I think I got is how I can do this in Flow and PowerApps.

Do have to do a bit additional testing though but things seem to work.

Many thanks for your help!

Much appreciated.

Regards,

Ludwig

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,891)