cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
seanatron
Advocate I
Advocate I

Creating a Data Table using Split

I would like to create a table from a TextInput list using Split. The table will need to return all rows found that contain the name in the Input. This works fine without the split:

Filter('[dbo].[sqlTable]',TextInput1.Text = sqlCol)

 

Now, if I split to a collection, or within the Filter, it stops working, but I have no "red line" errors:

ForAll(Split(TextInput1.Text,","),Filter('[dbo].[sqlTable]',Result = sqlCol))

 

And this is a version of spliting into a collection first...same issue, no errors, but no data will populate:

ClearCollect(splitem,Split(TextInput1.Text,","));

ClearCollect(theList,ForAll(splitem,Filter('[dbo].[sqlTable]',Result = sqlCol)))

 

Any ideas on what I am missing/doing incorrectly or need to add?

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Hi.

 

According to the docs (link below), the ForAll() function returns a table of the results of the formula. However, it does not specify any special behavior if the formula result is a table. In your third code snippet --

ClearCollect(splitem,Split(TextInput1.Text,","));
ClearCollect(theList,ForAll(splitem,Filter('[dbo].[sqlTable]',Result = sqlCol)))

It would be most reasonable that the collection, theList, would be a table of tables. In PA Studio (maybe in the Web Editor but I don't use that), you could go File in the Menu Bar > Collections on the side bar > theList under the list of collections, and you'll see gray-ish rectangles for values, instead of the expected column values. If not, then I'm wrong and ignore what I said.

https://docs.microsoft.com/en-us/powerapps/functions/function-forall

 

In any case, I may have something that could work.

If delegation isn't an issue for you (i.e. you don't need to work with 500+ records), then you can use the in operator.

Reference: https://docs.microsoft.com/en-us/powerapps/functions/operators

Like this:

Filter( '[dbo].[sqlTable]', sqlCol in Split(TextInput1.Text, ",").Result )

 

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi.

 

According to the docs (link below), the ForAll() function returns a table of the results of the formula. However, it does not specify any special behavior if the formula result is a table. In your third code snippet --

ClearCollect(splitem,Split(TextInput1.Text,","));
ClearCollect(theList,ForAll(splitem,Filter('[dbo].[sqlTable]',Result = sqlCol)))

It would be most reasonable that the collection, theList, would be a table of tables. In PA Studio (maybe in the Web Editor but I don't use that), you could go File in the Menu Bar > Collections on the side bar > theList under the list of collections, and you'll see gray-ish rectangles for values, instead of the expected column values. If not, then I'm wrong and ignore what I said.

https://docs.microsoft.com/en-us/powerapps/functions/function-forall

 

In any case, I may have something that could work.

If delegation isn't an issue for you (i.e. you don't need to work with 500+ records), then you can use the in operator.

Reference: https://docs.microsoft.com/en-us/powerapps/functions/operators

Like this:

Filter( '[dbo].[sqlTable]', sqlCol in Split(TextInput1.Text, ",").Result )

 

 

View solution in original post

That was it! I was trying the "in" operator but I did not have it correct. Also, you were correct, the Collections theList was created but  the values were gray.

 

 

Thank you so much!

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors
Top Kudoed Authors
Users online (2,319)