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 Platform Community / Forums / Power Apps / Filter gallery source ...
Power Apps
Unanswered

Filter gallery source based on radio button

(0) ShareShare
ReportReport
Posted on by 183

Hi All,

 

I am trying to filter my gallery items based on the radio button selection.  I have a radio button with 3 items in the list and have it working with only two of the items (see code below).  I would like the gallery to show items for this week, this month, or show all based on the column named "Milestone Date".

 

I have also tried setting the gallery items (Gallery1) to a variable but wasn't able to get it to work.

 

Radio Button Items:

This Week

This Month

Show All

 

If(Radio1.Selected.Value = "This Week", 
Filter('PM - RK Project Schedule', 'Milestone Date'>=Today()-Weekday(Today())+2 && 'Milestone Date'<=Today()+(9-Weekday(Today()))),
'PM - RK Project Schedule'
)

 

 

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @burliad 

    In PowerApps, it is far easier to put your calculations in your data rather than in your formula.  So, utilize the Items of the Radio control to provide the data for your formula.

     

    Change your Items property of your Radio Control to:

    With({_startOfWeek: DateAdd(Today(), -Weekday(Today(), StartOfWeek.MondayZero)),
     _startOfMonth: Date(Year(Today()), Month(Today()), 1)},
    
     Table({Value: "This Week", StartDate: _startOfWeek, EndDate: DateAdd(_startOfWeek, 6)},
     {Value: "This Month", StartDate: _startOfMonth, EndDate: DateAdd(DateAdd(_startOfMonth, 1, Months), -1)}, 
     {Value: "Show All", StartDate: Blank(), EndDate: Blank()}
     )
    )
    

     

    Then set your Items property of your Gallery to:

    Filter('PM - RK Project Schedule', 
     (IsBlank(Radio1.Selected.StartDate) || ('Milestone Date' >= Radio1.Selected.StartDate)) &&
     (IsBlank(Radio1.Selected.EndDate) || ('Milestone Date' <= Radio1.Selected.EndDate))
    )

     

    I hope this is helpful for you.

  • burliad Profile Picture
    183 on at

    Thank you Randy,

     

    That did it!  Not sure why that worked but thank you!

  • burliad Profile Picture
    183 on at

    If I wanted to use a sort would the sort go in the gallery or the radio?

  • burliad Profile Picture
    183 on at

    I got it.  Used a sort on the gallery.

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @burliad 

    Yes, review the pattern of how to do that.  It is very much how PowerApps works best and it will save you lots of work in the future.

    Glad it all worked for you!

  • TrayH Profile Picture
    383 on at

    Thank you for this Randy! I know this is an older comment but I was able to use it to place some date filtering on my gallery.

     

    Only thing I'm trying to figure out now is how to correctly add some sorting to it. For example, I want the default sort of the gallery to be descending rather than ascending. I know how to do that on its own, but now that I've added the filtering I'm not sure where to place the sort in the formula.

     

    This is what I currently have in the Items property of my gallery - 

    Filter('SPDevModern_List_FailsPolicyReview', 
     (IsBlank(rdoDateSelect.Selected.StartDate) || (Created >= rdoDateSelect.Selected.StartDate)) &&
     (IsBlank(rdoDateSelect.Selected.EndDate) || (Created <= rdoDateSelect.Selected.EndDate))
    )

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