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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Apps
Unanswered

Gallery Filtering

(1) ShareShare
ReportReport
Posted on by 34
Hi guys...
 
I have a gallery pulling data from a sharepoint list.  I already have some filtering set on the items property but now I'm getting worried about the volume of records potentially so I want to filter some more.
 
Here is my gallery and you can see that I have given some user filter choices:
 
 
 
I have the gallery set to always sort in "Time In" order and here is the current default filter on the items property:
 
 
SortByColumns(
    Filter('Gatehouse Logbook',
        StartsWith(Surname,cbSearchSurname2_1.Value),
            And(
                Or(IsBlank(cbSearchStatus2_1.Selected.Value),
                    Status.Value = cbSearchStatus2_1.Selected.Value),
                Or(IsBlank(cbSearchReason2_1.Selected.Value),
                    Reason.Value = cbSearchReason2_1.Selected.Value),
                Or(IsBlank(cbSearchDateStart2_1.SelectedDate),
                    'Time in' >= cbSearchDateStart2_1.SelectedDate),
                Or(IsBlank(cbSearchDateEnd2_1.SelectedDate),
                    'Time in' <= cbSearchDateEnd2_1.SelectedDate),
                Or(IsBlank(varToday),
                    (Status.Value="Expected" || Status.Value="Logged in")  And ('Time in'<=DateAdd(Today(),1))
                )
            ))
    ,
"Timein",If(varSortDirection=SortOrder.Ascending, SortOrder.Descending, SortOrder.Descending))
 
I would like to achieve a default filter state of records only going back 1 month (Time In) but also retain the ability for the user to search the entire record collection for anything they put into the search fields.
 
Hope someone can help me find what I'm missing.
 
 
Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,360 Super User 2025 Season 2 on at
     
    So essentially you need to have a way for them to check/select to search all..
     
    And in your items have an If to see if its selected or now
     
    Essentially like
     
    P.S. When you ask for help with Code please PASTE your code in, we don't have time to write peoples
    code each time and then modify. pretty please.
    
    
    If (IsBlank() And IsBlank etc checking all variables and controls, 
        /*This one would be where you would do your filter since they selected nothing
        However, you said you only wanted to go back 1 month. That term always makes me 
        go ugg a little because months are not all the same,
        so you need to pick a number like 31 (max days in a month) or 30 or whatever.
    
        Now for the actual code you would change what you have above
        for me the best way to do it is to run your query by one of these ways
    
        1. Assume you have a Field you can do a Today - 30 on for a month. This will insure that
           its only picking days that would be within the last month. Add that into your
           Filters and call it day, you would need to do Column <= Date and Column >= Date - 30 days
           where you use the addDays(ColumnDate, -30) . I know it says addDays and I used a negative
           thats how it works
        
    ,
    // Here is where you put your standard Expression you already have
    )
     
  • Overused Profile Picture
    34 on at
     
    Thanks for your response - I have corrected my code to help.
     
    I added this line but the effect is that all of the user searches then only take place on records in the last 30 days.  I want the default view to be 30 days to assist with potential delegation problems if there are too many records but I want the cbsearch fields to allow the user to search the entire SP list.
     
    SortByColumns(
        Filter('Gatehouse Logbook',
            StartsWith(Surname,cbSearchSurname2_1.Value),
            And('Time in' >=DateAdd(Today(), -30)),
                And(
                    Or(IsBlank(cbSearchStatus2_1.Selected.Value),
                        Status.Value = cbSearchStatus2_1.Selected.Value),
                    Or(IsBlank(cbSearchReason2_1.Selected.Value),
                        Reason.Value = cbSearchReason2_1.Selected.Value),
                    Or(IsBlank(cbSearchDateStart2_1.SelectedDate),
                        'Time in' >= cbSearchDateStart2_1.SelectedDate),
                    Or(IsBlank(cbSearchDateEnd2_1.SelectedDate),
                        'Time in' <= cbSearchDateEnd2_1.SelectedDate),
                    Or(IsBlank(varToday),
                        (Status.Value="Expected" || Status.Value="Logged in")  And ('Time in'<=DateAdd(Today(),1))
                    )
                ))
        ,
    "Timein",If(varSortDirection=SortOrder.Ascending, SortOrder.Descending, SortOrder.Descending))

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard