Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Help with Filtering a gallery based on multiple variables

(1) ShareShare
ReportReport
Posted on by 391
Greetings! I have a gallery connected to an SP list. I have three buttons that filter based on date. I have been messing around with this for about an hour and can't get it to work.

My goal is if someone clicks the button listed as "Today" it will show info for today. If they click "Yesterday" it will show the previous days info, and Daily would be all the info!

Here is my code that is in the item property of my gallery!
If(
    VarToday = true,
    Filter(
        TimeTracker,
        UpdatedActivityDateTime = Today(),
        Title = EmployeeName.Selected.Value
    )
) Or If(
    VarYesterday = true,
    Filter(
        TimeTracker,
        UpdatedActivityDateTime = Today() - 1,
        Title = EmployeeName.Selected.Value
    )
) Or If(
    VarDaily = true,
    Filter(
        TimeTracker,
        Title = EmployeeName.Selected.Value
    )
)

TIA for any assistance!

best, 

CodyO
Categories:
  • CodyO Profile Picture
    391 on at
    Help with Filtering a gallery based on multiple variables
    @Chris Ludwig, 
    I ended up going with your recommendation of using a date field. I was over complicating it by trying to use buttons to set the variables and the date field seems to just be an easier approach. Thank you for the suggestion and help!
  • Verified answer
    Chris Ludwig Profile Picture
    34 on at
    Help with Filtering a gallery based on multiple variables
    Hello,
    I would generally recommend filtering via a date field - this gives the user more options. To increase usability, I would also recommend the buttons shown in the screenshot and using these buttons to edit the value of the date field.
    To solve the error in your code, however, I would recommend creating a variable that contains a date. You can fill this variable with the buttons (e.g. if you click on the button ‘today’ you set the variable to the value ‘today()’ and so on...).  Then you don't have to react to the different button clicks in your filter, but only have one variable. It is important here that you also empty the variable again (if it is not possible to set a filter in your example) and also take into account in the filter that your variable can be empty. However, as you might have a problem here because you are comparing a DateField with an empty variable, I would recommend the approach with the date field, as already mentioned 
  • Michael E. Gernaey Profile Picture
    41,020 Super User 2025 Season 1 on at
    Help with Filtering a gallery based on multiple variables
    Hi
     
    You did not explain what isn't working, or details on the Fields that are holding the data.
     
    Also I dont see the data (the actual data, so I can see what it looks like)
     
    Also you image has all errors. Those type of Errors usually mean those fields do not exist in the Items that are being returned, But if you are filtering on a table, it doesn't care if there are zero, simply that it understands the Schema and those errors tell me it doesnt.
     
    Also, if you are trying to compare Today to a Date Time field, that would be impossible (or nearly) to match, because you will be off ine Hours, minutes or seconds

    Instead you should check the Date Part of the Value, against the DatePart of Today (or Now()) versus the entire string
    which I believe is the actual issue

    Please share the above, the data, your Items property, the errors etc and we can help you quickly

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

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,645 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard