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 / Toggle Button - Filter
Power Apps
Answered

Toggle Button - Filter

(0) ShareShare
ReportReport
Posted on by 26

I have a new Toggle Button and I would like to Filter the data as per Toggle - On or Off. If Toggle is ON I want the app to show only those records where Status = Open. Status is the Column Name. 

 

I am new to Powerapps. 

Categories:
I have the same question (0)
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @JV_DXB,

     

    You can get the value of a toggle control to determine whether it is on or off (true or false). You can then use an If function to filter your data based on this value.

     

     

    If(
     Toggle1.Value, //Will return true or false
     Filter( //If the toggle is on filter collection of data
     MyCollection,
     Status = "Open"
     ),
     MyCollection // If the toggle is off just show the unfiltered collection
    )

    //Replace MyCollection and Toggle1 with the name of your equivalent dataset and control

     

     

    You could set the items property of a gallery to this and it would filter based on if the toggle is on or off.

     

    Hope that helps Robot Happy

  • JV_DXB Profile Picture
    26 on at

    Hi @Anonymous ,

     

    Where do I add this code? To Toggle Button or browse gallery? 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @JV_DXB 

     

    If you wanted to display the data in a gallery you will need to add it to the items property of the gallery, where you would normally have the data source you want to show in the gallery (in my example this is MyCollection)

     

     

  • v-yuxima-msft Profile Picture
    Microsoft Employee on at

    Hi @JV_DXB ,

     

    What is your data source?And what is the column type of Status?

    Do you test with @Anonymous 's suggestion?If it works ok, please accept it as as solution.

    I test with SP list and two columns types, one is single line, one is choice type

    Data source:'20190523test' (my SP list name)

    20190523ToggleFilter1.PNG

    Status_S (single line)

    Status_Choice(choice type)

     

    App Test:

    20190523ToggleFilter2.PNG

    If the column type is single line, Gallery1.Items=If(Toggle1.Value=true,Filter('20190523test',Status_S = "Open"),'20190523test')

    If the column type is Choice,Gallery1.Items=If(Toggle1.Value=true,Filter('20190523test',Status_Choice.Value = "Open"),'20190523test')

     

    Hope this could be helpful.

     

    Best Regards.

    Yumia

  • JV_DXB Profile Picture
    26 on at

    Hello,

    I have tried the below code as guided by @Anonymous  but when I turn on Toggle I cannot search

     

    If(Toggle1.Value, Filter(Table1, 'Issue Status' = "OPEN"), SortByColumns(Search(Table1, TextSearchBox1.Text, "Description","From_x0020_","Info_x002f__x0020_Action","Issue_x0020_Status"), "Date", If(SortDescending1, Descending, Ascending)))

  • v-yuxima-msft Profile Picture
    Microsoft Employee on at

    Hi @JV_DXB 

     

    I think you wrong understanding of the functions using.

    Could you please reference this firstly?

    function-if

    function-filter-lookup

    function-sort

     

    Hope this could be helpful.

     

    Best Regards.

    Yumia

  • JV_DXB Profile Picture
    26 on at

    @Anonymous @v-yuxima-msft 

     

    Which function would give me the desired result? When Toggle is on I want to show all items with Status "Open" and when toggle is off, I want to show all items with Status "Closed". I am able to achieve this with below code but unable to search when toggle is ON.

     

    If(Toggle1.Value, Filter(Table1, 'Issue Status' = "OPEN"), SortByColumns(Search(Table1, TextSearchBox1.Text, "Description","From_x0020_","Info_x002f__x0020_Action","Issue_x0020_Status"), "Date", If(SortDescending1, Descending, Ascending)))

  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @JV_DXB 

     

    Looking at the formula you provided I think you are wanting to use the toggle to show items in a table with either a CLOSED status if the toggle is off or an OPEN status if the toggle is on. You also need to be able to use a text field to search content at the same time.

     

    You will need to pass the filtered table into the search function so the search is performed only on these results. Can you try using the following code in the items property of a gallery or table:

    If(Toggle1.Value, 
     SortByColumns(
     Search(
     Filter(Table1, 'Issue Status' = "OPEN"), 
     TextSearchBox1.Text, 
     "Description","From_x0020_","Info_x002f__x0020_Action","Issue_x0020_Status"
     ),
     "Date", 
     If(SortDescending1, Descending, Ascending)
     ),
     SortByColumns(
     Search(
     Filter(Table1, 'Issue Status' = "CLOSED"), 
     TextSearchBox1.Text, 
     "Description","From_x0020_","Info_x002f__x0020_Action","Issue_x0020_Status"
     ),
     "Date", 
     If(SortDescending1, Descending, Ascending)
     )
    )

    Hope this is what you were looking for Robot Happy

  • JV_DXB Profile Picture
    26 on at

    @Anonymous 

     

    Worked. Thanks.

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 July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard