cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
nyyanks1013
New Member

Complex combobox search

I'm attempting to build a search feature in a combobox in a PowerApps canvas app where there can be >17 billion permutations from multiple columns of choices.  

 

For example:

 

ItemIDcol01col02col03col04
Item1a,b,c1,2,3,4,5cd,g1,h5 
Item2w,x,y,zab,bd14,16,18,20c,d,e
etc    

 

Is there a way to set up a search where a user can start typing "bd16" and Item2 would be returned without creating a collection of all 17 billion+ possible permutations, maybe with MatchAll?  

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
nyyanks1013
New Member

Figured out a solution (takes a few steps):

- Added a hidden slider with default = Len(ComboBox.SearchText)

-In OnChange of slider, create temporary collection with a concatenated list of potential matches, then add those to the ComboBox data source/collection with concat function by item#

-Include added column in search field of combobox

 

Slider OnChange:

 

Clear(tempMatches);
ClearCollect(tempTable,AddColumns(DataSource,"Matches",
    With({      

a:ForAll(Split(Concat(Filter(Split(ThisRecord.'col01',","),Find(Lower(Result),Lower(ComboBox1.SearchText))>0).Result,Result,","),","),Result),    

b:ForAll(Split(Concat(Filter(Split(ThisRecord.'col02',","),Find(Lower(Result),Lower(ComboBox1.SearchText))>0).Result,Result,","),","),Result),       

c:ForAll(Split(Concat(Filter(Split(ThisRecord.'col03',","),Find(Lower(Result),Lower(ComboBox1.SearchText))>0).Result,Result,","),","),Result),      

d:ForAll(Split(Concat(Filter(Split(ThisRecord.'col04',","),Find(Lower(Result),Lower(ComboBox1.SearchText))>0).Result,Result,","),","),Result))
    },
    ForAll(Sequence(CountRows(a)) As A,
            ForAll(Sequence(CountRows(b)) As B,
                ForAll(Sequence(CountRows(c)) As C,
                    ForAll(Sequence(CountRows(d)) As D,
                         Collect(tempMatches,{ItemID:ID1,Matches:Concatenate(
                              Last(FirstN(a,A.Value).Value).Value,
                              Last(FirstN(b,B.Value).Value).Value,
                              Last(FirstN(c,C.Value).Value).Value,
                              Last(FirstN(d,D.Value).Value).Value)})
                    )
                )
            )
        )
    )
));

ClearCollect(DataSource2,AddColumns(ShowColumns(DataSource,"ID1"),"Matches",Concat(Filter(tempMatches,ItemID=ID1).Matches,Matches,",")));

 

 

 This only works for a specified number of columns, but that's acceptable for my purposes.  Would welcome any suggestions/comments if there's other methods to accomplish the dynamic search.

View solution in original post

2 REPLIES 2
RandyHayes
Super User
Super User

@nyyanks1013 

You can use the Search function and/or the in operator, but these will not be delegable.  So you need to first determine if your datasource record totals will exceed the maximum record limit of PowerApps.

If so, they you will encounter issues with getting accurate results.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
nyyanks1013
New Member

Figured out a solution (takes a few steps):

- Added a hidden slider with default = Len(ComboBox.SearchText)

-In OnChange of slider, create temporary collection with a concatenated list of potential matches, then add those to the ComboBox data source/collection with concat function by item#

-Include added column in search field of combobox

 

Slider OnChange:

 

Clear(tempMatches);
ClearCollect(tempTable,AddColumns(DataSource,"Matches",
    With({      

a:ForAll(Split(Concat(Filter(Split(ThisRecord.'col01',","),Find(Lower(Result),Lower(ComboBox1.SearchText))>0).Result,Result,","),","),Result),    

b:ForAll(Split(Concat(Filter(Split(ThisRecord.'col02',","),Find(Lower(Result),Lower(ComboBox1.SearchText))>0).Result,Result,","),","),Result),       

c:ForAll(Split(Concat(Filter(Split(ThisRecord.'col03',","),Find(Lower(Result),Lower(ComboBox1.SearchText))>0).Result,Result,","),","),Result),      

d:ForAll(Split(Concat(Filter(Split(ThisRecord.'col04',","),Find(Lower(Result),Lower(ComboBox1.SearchText))>0).Result,Result,","),","),Result))
    },
    ForAll(Sequence(CountRows(a)) As A,
            ForAll(Sequence(CountRows(b)) As B,
                ForAll(Sequence(CountRows(c)) As C,
                    ForAll(Sequence(CountRows(d)) As D,
                         Collect(tempMatches,{ItemID:ID1,Matches:Concatenate(
                              Last(FirstN(a,A.Value).Value).Value,
                              Last(FirstN(b,B.Value).Value).Value,
                              Last(FirstN(c,C.Value).Value).Value,
                              Last(FirstN(d,D.Value).Value).Value)})
                    )
                )
            )
        )
    )
));

ClearCollect(DataSource2,AddColumns(ShowColumns(DataSource,"ID1"),"Matches",Concat(Filter(tempMatches,ItemID=ID1).Matches,Matches,",")));

 

 

 This only works for a specified number of columns, but that's acceptable for my purposes.  Would welcome any suggestions/comments if there's other methods to accomplish the dynamic search.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

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