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

Forall on collection with isMatch()

I am trying to use a ForAll on a collection called TestInfo that will check if the "Time" column will match "5:00".

 

I tried

ForAll(TestInfo, IsMatch(TestInfo.Time, "3:00")).

 

Error Message says "Invalid argument type (table). Expecting a Text value instead". How would i get the text value of the collection items and does the Forall return a new table with a true and false values ?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Forall on collection with isMatch()

Hi @Buddy2019 ,

Could you please share a bit more about your scenario?

Do you want to detect if the time value within the Time column in your TestInfo collection match "5:00"?

 

Based on the screenshot that you provided, I think the Time column (in your TestInfo collection) contains a Table value. So the result the TestInfo.Time formula returned is a Table value rather than Text value. But the first argument of the IsMatch function is required to provide a Text value.

 

I have made a test on my side, please take a try with the following workaround:8.JPG

 

9.JPG

 

10.JPG

Set the OnStart property of the App control to following:

 

ClearCollect(
             TestInfo,
             {ProductName: "PowerApps", Time: Table({StartTime: "07/26/2019 3:00 PM"}, {StartTime: "07/26/2019 12:00 PM"})},
             {ProductName: "MS Flow", Time: Table({StartTime: "07/26/2019 5:00 PM"}, {StartTime: "07/26/2019 6:00 PM"})}
)

The TestInfo data structure as below:13.JPG

 

Set the OnSelect property fo the "Execute Match" button to following (nested ForAll functions):

ForAll(
       TestInfo,
       ForAll(
              Time,
              If(
                  IsMatch(StartTime, "\d{1,2}\/\d{1,2}\/\d{4} 5:00 (AM|PM)"),
                  Collect(MatchRecords, {ProductName: ProductName, MatchedTime: StartTime})
              )
        )
)

On your side, you may type following:

ForAll(
       TestInfo,
       ForAll(
              Time,
              If(
                  IsMatch(StartTime, "\d{1,2}\/\d{1,2}\/\d{4} 5:00 (AM|PM)"),
                  Collect(
MatchRecords,
{
Column1: Column1,
Column2: Column2,
...
MatchedTime: StartTime
}
) ) ) )

Note: The Column1, Column2, ... represents the columns in your TestInfo collection.

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

MatchRecords

When you press the "Execute Match" button, above Data Table control would be populated with matched records and corresponding matched time.

 

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

3 REPLIES 3
Highlighted
Super User
Super User

Re: Forall on collection with isMatch()

Hi @Buddy2019 

In answer to your question, the ForAll function doesn't return a table with true and false values. To do this, you can use the AddColumns function rather than ForAll. The syntax would look like this:

 

AddColumns(TestInfo, 
"TimeMatch",
IsMatch(Time, "5:00")
)

This function returns a table with a new column called TimeMatch. The field value will be true when the time matches 5:00.

The Concat function can help you extract text values from a table. There are more details here.

https://docs.microsoft.com/en-gb/powerapps/maker/canvas-apps/functions/function-concatenate

 

 

 

 

Highlighted
Dual Super User
Dual Super User

Re: Forall on collection with isMatch()

Hi @Buddy2019 

 

Try the following code:

 

ForAll(TestInfo, If(IsMatch(Text(TestInfo[@StartTime]), "3:00",MatchOptions.Contains),Collect(newcollection,TestInfo[@StartTime])))

 

ForAll does not create a new collection, you would have to create one withing ForAll

The above example will create a new collection for you

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Highlighted
Community Support
Community Support

Re: Forall on collection with isMatch()

Hi @Buddy2019 ,

Could you please share a bit more about your scenario?

Do you want to detect if the time value within the Time column in your TestInfo collection match "5:00"?

 

Based on the screenshot that you provided, I think the Time column (in your TestInfo collection) contains a Table value. So the result the TestInfo.Time formula returned is a Table value rather than Text value. But the first argument of the IsMatch function is required to provide a Text value.

 

I have made a test on my side, please take a try with the following workaround:8.JPG

 

9.JPG

 

10.JPG

Set the OnStart property of the App control to following:

 

ClearCollect(
             TestInfo,
             {ProductName: "PowerApps", Time: Table({StartTime: "07/26/2019 3:00 PM"}, {StartTime: "07/26/2019 12:00 PM"})},
             {ProductName: "MS Flow", Time: Table({StartTime: "07/26/2019 5:00 PM"}, {StartTime: "07/26/2019 6:00 PM"})}
)

The TestInfo data structure as below:13.JPG

 

Set the OnSelect property fo the "Execute Match" button to following (nested ForAll functions):

ForAll(
       TestInfo,
       ForAll(
              Time,
              If(
                  IsMatch(StartTime, "\d{1,2}\/\d{1,2}\/\d{4} 5:00 (AM|PM)"),
                  Collect(MatchRecords, {ProductName: ProductName, MatchedTime: StartTime})
              )
        )
)

On your side, you may type following:

ForAll(
       TestInfo,
       ForAll(
              Time,
              If(
                  IsMatch(StartTime, "\d{1,2}\/\d{1,2}\/\d{4} 5:00 (AM|PM)"),
                  Collect(
MatchRecords,
{
Column1: Column1,
Column2: Column2,
...
MatchedTime: StartTime
}
) ) ) )

Note: The Column1, Column2, ... represents the columns in your TestInfo collection.

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

MatchRecords

When you press the "Execute Match" button, above Data Table control would be populated with matched records and corresponding matched time.

 

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

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

Top Solution Authors
Top Kudoed Authors
Users online (7,101)