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 / Filter gallery source ...
Power Apps
Answered

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,299 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,299 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 476

#2
WarrenBelz Profile Picture

WarrenBelz 365 Most Valuable Professional

#3
Vish WR Profile Picture

Vish WR 339

Last 30 days Overall leaderboard