Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

Strange issue with Gallery when using Search()

(0) ShareShare
ReportReport
Posted on by 15

I'm encountering a strange bug when using Search on an SQL View. 

I have a TextInput (the searchbar) and a Gallery displaying items from a SQL View. When there is text in the searchbar, the Search() functions works as expected and the Gallery items are filtered.

However, a strange issue occurs when I clear the searchbar. Please see the spoiler below:

Spoiler (Highlight to read)
PowerApps Search Bug

Here's the code for Items in the Gallery:

Sort(
 Filter(
 If(Len(TInSearch_Request.Text) > 0, Search('[dbo].[VW_PendingItems]', TInSearch_Request.Text, "Title"), '[dbo].[VW_PendingItems]'),
 && Approver = User().Email
 ),
 CreatedDateTime, Descending
)

Am I doing something wrong here? 

Categories:
  • Verified answer
    TCheong Profile Picture
    15 on at
    Re: Strange issue with Gallery when using Search()

    @iAm_ManCat, thanks for your time.

    I've done some testing of my own, and this issue seems to only happen with SQL Server Views. It does not occur with other datasources (e.g. regular SQL Server tables, collections, etc.) as far as I know.

    Also, I've found that refreshing the SQL Server View datasource (i.e. Refresh("[dbo].[VW_PendingItems]") after clearing the searchbar returns the Gallery Items to its original correct state. As a workaround for now, I'll manually refresh the datasource every time the searchbar is empty.

    I do hope this issue gets fixed though, it's preventing me from achieving the responsiveness that I want for the app.

     

  • iAm_ManCat Profile Picture
    18,206 Most Valuable Professional on at
    Re: Strange issue with Gallery when using Search()

    Ok, thanks for clarifying 🙂

     

    I recreated your code for the Items section exactly using my data and didn't run into the same issue, when I clear using backspace while still in the bar it shows the exact correct items, no duplicates, so I'm not sure what the issue may be.

     

    Sorry I couldn't help any further!

     

    image.png

  • TCheong Profile Picture
    15 on at
    Re: Strange issue with Gallery when using Search()

    Hi @iAm_ManCat, thanks for pointing that out.

    I had removed some filter formulas in my original post for simplicity's sake, and forgot to remove the &&. I'm using the correct syntax in the actual code though.

    I tried using just 'Approver = User().Email' as the only filter formula. Unfortunately, the same issue still occurs.

  • iAm_ManCat Profile Picture
    18,206 Most Valuable Professional on at
    Re: Strange issue with Gallery when using Search()

    Hi @TCheong

    Sort(
     Filter(
     If(Len(TInSearch_Request.Text) > 0, Search('[dbo].[VW_PendingItems]', TInSearch_Request.Text, "Title"), '[dbo].[VW_PendingItems]'),
     && Approver = User().Email
     ),
     CreatedDateTime, Descending
    )

    When I pasted your formula into PowerApps, I could see that it was struggling to see where your conditional check ended within the Filter argument:
    image.png

     

    Could you try removing the && from the formula (as it is implied by being the part of the Filter function that is tested against)?

     

    Cheers,

    @iAm_ManCat

  • TCheong Profile Picture
    15 on at
    Re: Strange issue with Gallery when using Search()

    Hi @dinusc,
    The app works as expected up until I clear the searchbar. Take note of the first item in the gallery. After clearing the searchbar, the Gallery should show the original unfiltered list of items. However, the first item in the list seems to have turned into a duplicate of the second item.

  • dinusc Profile Picture
    Microsoft Employee on at
    Re: Strange issue with Gallery when using Search()

    Hello @TCheong,

    Could you please describe what the issue is? It is not clear from the attached animated image.

    Thank you.

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,668 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard