web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Multilevel Search Func...
Power Apps
Suggested Answer

Multilevel Search Functionality in canvas app

(0) ShareShare
ReportReport
Posted on by
In Canvas Apps, I’m implementing a multi-level search functionality for a gallery. For example, when a user types keys like A, B, and C, the gallery should return results containing all three values accordingly. I have used the comma ( , ) as a separator. The gallery contains both Choice and Text columns, and my data source is SharePoint only. The SharePoint list has around 50,000 records, so I need the solution to be fully delegable as well. Please suggest how I can achieve this. 
 
1. How to load all the 50k records in the search gallery in fast & optimal way to search in the Sharepoint list records?
 
Note - Currently I have used the collection to fastly load the data. But, we have this restriction of 2k records can be loaded at a time. How to overcome from this and search the records from total 50k records in sharepoint.

Here is the sample code
 
SortByColumns(
    With(
        {
            inputScore:
                Value(
                    Len(SearchInput1.Text) -
                    Len(
                        Substitute(
                            SearchInput1.Text,
                            ",",
                            ""
                        )
                    )
                )
        },
        With(
            {
                final_query:
                    If(
                        inputScore = 0,
                        SearchInput1.Text & ",,",
                        inputScore = 1,
                        SearchInput1.Text & ",",
                        inputScore >= 2,
                        SearchInput1.Text
                    )
            },
            With(
                {
                    filter_text:
                        Split(
                            final_query,
                            ","
                        )
                },
                With(
                    {
                        val1: Index(filter_text,1).Value,
                        val2: Index(filter_text,2).Value,
                        val3: Index(filter_text,3).Value
                    },
                    Filter(
                        Filter(
                            Filter(
                                [@SHAREPOINT_LIST_Data],
                                'Products'.Value in colUserProducts,
                                IsBlank(SearchInput1.Text) ||
                                (
                                    val1 in program.Value ||
                                    val1 in 'Status' ||
                                    val1 in category_created_by ||
                                    val1 in 'Item Number' ||
                                    val1 in 'QuoteNumber'
                                )
                            ),
                            IsBlank(SearchInput1.Text) ||
                            (
                                    val2 in program.Value ||
                                    val2 in 'Status' ||
                                    val2 in category_created_by ||
                                    val2 in 'Item Number' ||
                                    val2 in 'QuoteNumber'
                            )
                        ),
                        IsBlank(SearchInput1.Text) ||
                        (
                                    val3 in program.Value ||
                                    val3 in 'Status' ||
                                    val3 in category_created_by ||
                                    val3 in 'Item Number' ||
                                    val3 in 'QuoteNumber'
                        )
                    )
                )
            )
        )
    ),
    "Created",
    SortOrder.Descending
)
 
Categories:
I have the same question (0)
  • Suggested answer
    11manish Profile Picture
    3,333 on at
    Your current formula is too complex and largely non-delegable for a 50k-record SharePoint list.
     
    Instead:
    • Add indexed SharePoint columns.
    • Avoid collections for the main dataset.
    • Avoid in, Split, and nested filters on large lists.
    • Use delegable Filter() + StartsWith() wherever possible.
    • If users must search multiple comma-separated keywords (A,B,C) across many fields, move the search logic to Power Automate or Dataverse Search rather than trying to do it entirely in Canvas Apps.
    This will give you the best performance, accuracy, and scalability for 50,000+ records.
  • Suggested answer
    WarrenBelz Profile Picture
    155,840 Most Valuable Professional on at
    Firstly before I say anything else, the in function is not Delegable with SharePoint for any amount of records and you have no other Delegable criteria posted to "pre-filter" to under 2,000 records, so anything over 2,000 records will simply not return the full result. The best you are going to do is using StartsWith()  as below (although you can us in on the bottom search providing you get less than 2,000 records from the rest above).
    With(
       {
          inputScore:
          Value(
             Len(SearchInput1.Text) -
             Len(
                Substitute(
                   SearchInput1.Text,
                   ",",
                   ""
                )
             )
          )
       },
       With(
          {
             filter_text:
             Split(
                SearchInput1.Text & 
                Switch(
                   inputScore,
                   0, ",,",
                   1, ",",
                   2, ""
                ),
                ","
             )
          },
          With(
             {
                val1: Index(filter_text, 1).Value,
                val2: Index(filter_text, 2).Value,   
                val3: Index(filter_text, 3).Value
             },
             With(
                {
                   _Data:
                   SortByColumns(
                      Filter(
                         [@SHAREPOINT_LIST_Data],
                         Len(SearchInput1.Text) ||
                         StartsWith(
                            val1,
                            program.Value
                         ) ||
                         StartsWith(
                            val1,
                            Status
                         ) ||
                         StartsWith(
                            val1,
                            category_created_by
                         ) ||
                         StartsWith(
                            val1,
                            'Item Number' 
                         ) ||
                         StartsWith(
                            val1,
                            'QuoteNumber'
                         ) ||
                         StartsWith(
                            val2,
                            program.Value
                         ) ||
                         StartsWith(
                            val2,
                            Status
                         ) ||
                         StartsWith(
                            val2,
                            category_created_by
                         ) ||
                         StartsWith(
                            val2,
                            'Item Number' 
                         ) ||
                         StartsWith(
                            val2,
                            'QuoteNumber'
                         ) ||
                         StartsWith(
                            val3,
                            program.Value
                         ) ||
                         StartsWith(
                            val3,
                            Status
                         ) ||
                         StartsWith(
                            val3,
                            category_created_by
                         ) ||
                         StartsWith(
                            val3
                            'Item Number' 
                         ) ||
                         StartsWith(
                            val3,
                            'QuoteNumber'
                         )
                      ),
                      "Created",
                      SortOrder.Descending
                   )
                },
                Filter(
                   _Data,
                   'Products'.Value in colUserProducts
                )
             )
          )
       )
    )
    I have added a few optimising suggestions as well. Also in a list of that size, you need to index (in SharePoint) every column incolved in the code above and also may need a field name in colUserProducts that you are searching in.
     
    Please Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like
    Visit my blog
    Practical Power Apps    LinkedIn  
  • Suggested answer
    MS.Ragavendar Profile Picture
    7,431 Super User 2026 Season 1 on at
     
    With(
        {
            searchTerms: Split(Substitute(SearchInput1.Text," ",""), ",")
        },
        SortByColumns(
            Filter(
                [@SHAREPOINT_LIST_Data],
               
                // Delegable base filter
                'Products'.Value in colUserProducts &&
               
                // Term 1
                (IsBlank(Index(searchTerms,1).Value) ||
                    StartsWith(program.Value, Index(searchTerms,1).Value) ||
                    StartsWith('Status', Index(searchTerms,1).Value) ||
                    StartsWith(category_created_by, Index(searchTerms,1).Value) ||
                    StartsWith('Item Number', Index(searchTerms,1).Value) ||
                    StartsWith('QuoteNumber', Index(searchTerms,1).Value)
                ) &&
               
                // Term 2
                (IsBlank(Index(searchTerms,2).Value) ||
                    StartsWith(program.Value, Index(searchTerms,2).Value) ||
                    StartsWith('Status', Index(searchTerms,2).Value) ||
                    StartsWith(category_created_by, Index(searchTerms,2).Value) ||
                    StartsWith('Item Number', Index(searchTerms,2).Value) ||
                    StartsWith('QuoteNumber', Index(searchTerms,2).Value)
                ) &&
               
                // Term 3
                (IsBlank(Index(searchTerms,3).Value) ||
                    StartsWith(program.Value, Index(searchTerms,3).Value) ||
                    StartsWith('Status', Index(searchTerms,3).Value) ||
                    StartsWith(category_created_by, Index(searchTerms,3).Value) ||
                    StartsWith('Item Number', Index(searchTerms,3).Value) ||
                    StartsWith('QuoteNumber', Index(searchTerms,3).Value)
                )
            ),
            "Created",
            Descending
        )
     
    ✅If this helped, please Accept as Solution to help others ❤️ A Like is appreciated 🏷️ Tag @MS.Ragavendar for follow-ups.
  • WarrenBelz Profile Picture
    155,840 Most Valuable Professional on at
    A quick follow-up to see if you received the answer you were looking for. Happy to assist further if not.
     
    Please Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like ♥
    Visit my blog
    Practical Power Apps    LinkedIn   

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 424

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
11manish Profile Picture

11manish 290

Last 30 days Overall leaderboard