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 / Gallery not filtering ...
Power Apps
Suggested Answer

Gallery not filtering unless combobox filters are selected at least once

(1) ShareShare
ReportReport
Posted on by 28
Hi All,
 
I'm having an issue with my gallery that filtering appears to be not working until I interact with all my combo-box filter items at least once.

I have a gallery in my power app, and I have 3 combo-boxes (StatusCombo, DateCombo and OwnerCombo) and one text field (RequestSearchText) that is used to filter items within the gallery.
 
When my app loads, I can see all gallery items as I would expect. But the moment I interact with any of the above filters, the gallery appears empty.
The gallery will remain empty until I select a value with all 3 combo-boxes, which will then cause the gallery to populate based on the selected filters.

If I then clear the filters, the gallery will now populate as expected according to which ever filters I select, even if I only filter using one or two combo-boxes. But they won't work until each combo box value has been changed once.
 
This could be problematic if users attempt to filter for themselves as owners and see nothing in the gallery that requires their action. I'd like the filters to work as intended immediately as the app starts.
Would anyone know what could be causing this odd behavior from my app?
 
At first I thought the InputTextPlaceholder property of the combo boxes could be causing the value of the combo box to be causing the value to be changed, but even after clearing this, it still doesn't work as intended.
Below I've noted the formula I'm using in the Items property of my gallery.
 
 
If (
    //trying everything to ensure gallery is unfiltered if no filters are selected
    ((IsEmpty(StatusCombo.SelectedItems) || IsBlank(StatusCombo.SelectedItems) || CountRows(StatusCombo.SelectedItems) = 0) && 
        (IsEmpty(OwnerCombo.SelectedItems) || IsBlank(OwnerCombo.SelectedItems) || CountRows(OwnerCombo.SelectedItems) = 0) && 
        (IsEmpty(DateCombo.SelectedItems) || IsBlank(DateCombo.SelectedItems)  || CountRows(DateCombo.SelectedItems) = 0) && 
        (IsBlank(RequestSearchText.Text) || RequestSearchText.Text = "")
    ),
    
    //if no filters are selected, list items in order based on SortDescending1    
    SortByColumns(
        'Surv_3PR_RequestList',
        "Created",
        If(SortDescending1, SortOrder.Descending, SortOrder.Ascending)
    ),
    
    //else sort by filters
    SortByColumns(
        With(
            {
                //get filters
                filterStatus: StatusCombo.SelectedItems,
                filterOwner:  OwnerCombo.SelectedItems,
                rangeLabel: If(
                    IsBlank(DateCombo.Selected),
                    "",
                    Coalesce(DateCombo.Selected.Label, "")
                )
            },
            With(
                {
                    //get date bounds from the label
                    startDate:
                        Switch(
                            rangeLabel,
                            "Last 7 Days",  DateAdd(Today(), -6, TimeUnit.Days),   
                            "Last 14 Days", DateAdd(Today(), -13, TimeUnit.Days),
                            "Last 30 Days", DateAdd(Today(), -29, TimeUnit.Days),
                            "Last 90 Days", DateAdd(Today(), -89, TimeUnit.Days),
                            "This Year",    Date(Year(Today()), 1, 1),
                            "Last Year",    Date(Year(Today()) - 1, 1, 1),
                            Blank()
                        ),
                    endDate:
                        Switch(
                            rangeLabel,
                            "Last 7 Days",  Today(),
                            "Last 14 Days", Today(),
                            "Last 30 Days", Today(),
                            "Last 90 Days", Today(),
                            "This Year",    Today(),
                            "Last Year",    Date(Year(Today()) - 1, 12, 31),
                            Blank()
                        ),

                    //normalize the search text once
                    searchTxt: Lower(Trim(Coalesce(RequestSearchText.Text, "")))
                },
                Filter(
                    Surv_3PR_RequestList,

                    // filter by status (multi-select)
                    IsEmpty(filterStatus) || CountIf(filterStatus, Value = RequestStatus.Value) > 0,

                    // filter by owner
                    IsEmpty(filterOwner)  || CountIf(filterOwner, DisplayName = RequestOwner) > 0,
                    
                    //filter by date range
                    IsBlank(startDate) || Created >= DateTimeValue(startDate),
                    IsBlank(endDate)   || Created <  DateAdd(DateTimeValue(endDate), 1, TimeUnit.Days),

                    // filter by substring search across RequestorName and OffenderDetails
                    IsBlank(searchTxt) ||
                    Find(
                        searchTxt,
                        Lower(Coalesce(RequestorName, ""))
                    ) > 0 ||
                    Find(
                        searchTxt,
                        Lower(Coalesce(OffenderDetails, ""))
                    ) > 0 ||
                    Find(
                        searchTxt,
                        Lower(Coalesce(Title, ""))
                    ) > 0
                )
            )
        ),
        "Created",
        If(SortDescending1, SortOrder.Descending, SortOrder.Ascending)
    )

)
 
Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    155,838 Most Valuable Professional on at
    Hi @Bront,
    A bit to unpack here and the code below I am sure is not the final solution - some things to clarify: -
    • Which Combo Boxes are multiple or single selection ?
    • What is the Items and DisplayFieldsof the Combo Boxes ?
    • What type of fields are RequestOwner, RequestStatus and RequestorName and are they single or multiple values ?
    • You are using SharePoint here ? Is Delegation going to be an issue (there are a number of non-Delegable elements in there, so how big is your data set)
    With(
       {
          startDate:
          Switch(
             DateCombo.Selected.Label,
             "Last 7 Days",  Today() -6,
             "Last 14 Days", Today() -13,
             "Last 30 Days", Today() -29,
             "Last 90 Days", Today() -89,
             "This Year",    Date(Year(Today()), 1, 1),
             "Last Year",    Date(Year(Today()) - 1, 1, 1),
             Blank()
          ),
          endDate:
          Switch(
             DateCombo.Selected.Label,
             "Last 7 Days",  Today(),
             "Last 14 Days", Today(),
             "Last 30 Days", Today(),
             "Last 90 Days", Today(),
             "This Year",    Today(),
             "Last Year",    Date(Year(Today()) - 1, 12, 31),
             Blank()
          )
       },
       SortByColumns(
          Search(
             Filter(
                Surv_3PR_RequestList,
                IsEmpty(StatusCombo.SelectedItems) ||  RequestStatus.Value in StatusCombo.SelectedItems,
                IsEmpty(OwnerCombo.SelectedItems)  || RequestOwner.DisplayName in OwnerCombo.SelectedItems.DisplayName,
                Len(DateCombo.SelectedItems.Label) = 0 || Created >= startDate,
                IsBlank(endDate) || Created <  endDate + 1
             ),
             RequestSearchText.Text,
             RequestorName,
             OffenderDetails,
             Title
          )
       ),
       "Created",
       If(
          SortDescending1, 
          SortOrder.Descending, 
          SortOrder.Ascending
       )
    )
     
    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  
  • Bront Profile Picture
    28 on at
    Hello @WarrenBelz!
    Thanks for your post. And for bringing that to my attention as well!

    The way the delegation was underlined in my formula made me think it would be okay if the filters, were kept to a minimum.. but I'm starting to think now that if the dataset itself gets large (which over time it eventually will) I will run into problems.

    To answer your questions:
    • StatusCombo and OwnerCombo are Multi-Select, DateCombo is Single-Select.
    • StatusCombo and OwnerCombo derive data from SharePoint lists like you assumed.
    • StatusCombo Items property is:
      • Choices(Surv_3PR_RequestList.RequestStatus)
    • StatusCombo DisplayFields property is:
      • ["Value"]
    • DateCombo Items Property is:
        • [
              {Label: "Last 7 Days"},
              {Label: "Last 14 Days"},
              {Label: "Last 30 Days"},
              {Label: "Last 90 Days"},
              {Label: "This Year"},
              {Label: "Last Year"}
          ]
    • DateCombo DisplayFields property is:
      • ["Label"]
    • OwnerCombo Items Property is:
      • Surv_3PR_OwnerList.DisplayName
    • OwnerCombo DisplayFields Property is:
      • ["DisplayName"]
    • The dataset is small now, the Surv_3PR_Ownerlist will not grow very large, but the Surv_3PR_RequestList will eventually grow above the delegable item threshold
  • Suggested answer
    WarrenBelz Profile Picture
    155,838 Most Valuable Professional on at
     Hi @Bront,
    You have not given me the answer to this question
    • What type of fields are RequestOwner, RequestStatus and RequestorName and are they single or multiple values ? Also can you add Surv_3PR_OwnerList to the question -  I assume this is a Person field?
     
    I am trying to work out whether we are dealing with many-to-one or many-to-many filters here - and yes- you have some Delegation issues that need to be managed as best we can.
     
    So to progress this, I am going to assume that both RequestOwner and RequestStatus are multiple value fields and RequestOwner is a Person field. The code below is (sort of) Delegable as you should not get an error, except the top filter (on the dates), needs to return under your Data Row Limit for you to receive the full required dataset.
    With(
       {
          startDate:
          Switch(
             DateCombo.Selected.Label,
             "Last 7 Days",  Today() -6,
             "Last 14 Days", Today() -13,
             "Last 30 Days", Today() -29,
             "Last 90 Days", Today() -89,
             "This Year",    Date(Year(Today()), 1, 1),
             "Last Year",    Date(Year(Today()) - 1, 1, 1),
             Blank()
          ),
          endDate:
          Switch(
             DateCombo.Selected.Label,
             "Last 7 Days",  Today(),
             "Last 14 Days", Today(),
             "Last 30 Days", Today(),
             "Last 90 Days", Today(),
             "This Year",    Today(),
             "Last Year",    Date(Year(Today()) - 1, 12, 31),
             Blank()
          )
       },
       With(
          {
             _Data1:
             SortByColumns(
                Filter(
                   Surv_3PR_RequestList,
                   statrtDate = Blank() || Created >= startDate,
                   endDate = Blank() || Created <  endDate + 1
                ),
                "Created",
                If(
                   SortDescending1, 
                   SortOrder.Descending, 
                   SortOrder.Ascending
                )
             )
          },
          With(
             {
                _Data2:
                If(
                   IsEmpty(StatusCombo.SelectedItems),
                   _Data1,
                   Ungroup(
                      ForAll(
                         StatusCombo.SelectedItems As _Status,
                         Filter(
                            _Data1,
                            _Status.Value in RequestStatus.Value
                         )
                      ),
                      Value
                   )
                )
             },
             If(
                IsEmpty(OwnerCombo.SelectedItems),
                _Data2,
                Ungroup(
                   ForAll(
                      OwnerCombo.SelectedItems As _Owner,
                      Filter(
                         _Data2,
                         _Owner.DisplayName in RequestOwner.DisplayName
                      )
                   ),
                   Value
                )
             )
          )
       )
    )
     
    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  
  • Bront Profile Picture
    28 on at
    I appreciate your response!
    Please allow me to apologize for not answering that question in my previous response, and also not replying until today as I've just returned to work.
    In the SharePoint list named Surv_3PR_RequestList:
    • RequestOwner is actually a text field in SharePoint (single line of text). (I may need to adjust this to a person, however I've built my app and flows around this column being a text field so it might be something down the track)
    • RequestStatus is a choice field in SharePoint that does not allow multiple selections. 
    • RequestorName is also a text field (single line of text) and can represent anyone, even someone who is not within the organization so this one will always remain a text field.
    In the SharePoint list named Surv_3PR_OwnerList I have a column named User which is of type Person that does not allow multiple selections. 
    The column in this list named DisplayName is a calculated column based on other columns in the SharePoint list. The formula I've used is:
    =UPPER(LastName)&", "&PROPER(FirstName)
    (LastName and FirstName are single line text fields.)

    I hope that answers the question. Please let me know if more information is required. 

    I've attempted your above proposed solution, however since DisplayName is a text value, it has returned an error.
    The line:
    Len(DateCombo.SelectedItems.Label) = 0 || Created >= startDate,

    returned an error highlighting the = saying tables and numbers cannot be compared, which is strange since it's the result of a Len function.
  • WarrenBelz Profile Picture
    155,838 Most Valuable Professional on at
    Hi @Bront,
    Yes - that was a typing error - I have fixed on the original, however this is now a great deal simpler now you have advised we are not dealing with many-many queries here.
    Also SharePoint calculated columns really do not "play well" with Power Apps. If you are getting the correct list in the drop-down, then keep using it, but you really need to get it out of the filter. I have isolated the Delegable portion to the top filter (so at least you can bring back a sample up to your Data Row Limit to then process the non-Delegable portion locally).
    Try this for a start.
    With(
       {
          startDate:
          Switch(
             DateCombo.Selected.Label,
             "Last 7 Days", Today() -6,
             "Last 14 Days", Today() -13,
             "Last 30 Days", Today() -29,
             "Last 90 Days", Today() -89,
             "This Year", Date(Year(Today()), 1, 1),
             "Last Year", Date(Year(Today()) - 1, 1, 1),
             Blank()
          ),
          endDate:
          Switch(
             DateCombo.Selected.Label,
             "Last 7 Days", Today(),
             "Last 14 Days", Today(),
             "Last 30 Days", Today(),
             "Last 90 Days", Today(),
             "This Year", Today(),
             "Last Year", Date(Year(Today()) - 1, 12, 31),
             Blank()
          )
       },
       With(
          {
             _Data:
             SortByColumns(
                Filter(
                   Surv_3PR_RequestList,
                   startDate = Blank() || Created >= startDate,
                   endDate = Blank() || Created < endDate + 1,
                ),
                "Created",
                If(
                   SortDescending1, 
                   SortOrder.Descending, 
                   SortOrder.Ascending
                )
             )
          },
          Filter(
             AddColumns(
                _Data,
                OwnerName,
                Upper(LastName) & ", " & Proper(FirstName)
             ),			
             IsEmpty(StatusCombo.SelectedItems) || RequestStatus.Value in StatusCombo.SelectedItems.Value,
             IsEmpty(OwnerCombo.SelectedItems) || OwnerName in OwnerCombo.SelectedItems.DisplayName
          )
       )
    )
     
    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  
  • Bront Profile Picture
    28 on at
    Hi @WarrenBelz

    I gave the above a shot, I was getting some errors in the code as 

    Upper(LastName) & ", " & Proper(FirstName)
     
    Are columns in Surv_3PR_OwnerList as opposed to _Data which comes from the Surv_3PR_RequestList. I tried to correct this, but I was unsuccessful. I can't say my PowerApps Programming is at a very high level sadly.

    I tried to format it in a way such that I was doing an AddColumns function on Surv_3PR_OwnerLis, but I couldn't structure it in a way that didn't produce an error.
  • WarrenBelz Profile Picture
    155,838 Most Valuable Professional on at
    Hi @Bront,
    I cannot see your data, so am flying a little blind here - is it the RequestOwner field you need to compare it with ?
    Filter(
       _Data,	
       IsEmpty(StatusCombo.SelectedItems) || RequestStatus.Value in StatusCombo.SelectedItems.Value,
       IsEmpty(OwnerCombo.SelectedItems) || RequestOwner in OwnerCombo.SelectedItems.DisplayName
    )
     
    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  
  • WarrenBelz Profile Picture
    155,838 Most Valuable Professional on at
    Hi @Bront,
    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