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 / Help with Filtering a ...
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
Screenshot 2024-07-26 110749.png
Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,963 Moderator on at
    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
  • Verified answer
    Chris Ludwig Profile Picture
    34 on at
    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 
  • CodyO Profile Picture
    391 on at
    @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!

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 333 Most Valuable Professional

#2
11manish Profile Picture

11manish 184

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 86 Super User 2026 Season 1

Last 30 days Overall leaderboard