cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
lreinhard7
Level 8

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
Community Support Team
Community Support Team

Re: Elements contained in text

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
Dual Super User
Dual Super User

Re: Elements contained in text

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.
Community Support Team
Community Support Team

Re: Elements contained in text

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

lreinhard7
Level 8

Re: Elements contained in text

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

lreinhard7
Level 8

Re: Elements contained in text

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
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,046)