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 ?
Solved! Go to Solution.
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:
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:
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,
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
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
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:
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:
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,
User | Count |
---|---|
137 | |
127 | |
75 | |
72 | |
69 |
User | Count |
---|---|
220 | |
135 | |
78 | |
58 | |
54 |