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 / Filtering using a togg...
Power Apps
Answered

Filtering using a toggle button

(1) ShareShare
ReportReport
Posted on by 29

Hello

I have a simple app linked to an excel document. Excel docuement attached.

One of the columns (column G) in the excel spreadsheet is the status of an item which is either "Open" or "Closed". I would like to filter records shown in in the app when a field in one of the excel columns is "Open".  I'd like to use a toggle button as the control. I think I use an IF statement but not sure how to do it.

Any help would  be appreciated.

 

 

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    156,425 Most Valuable Professional on at

    Hi @jeremywoakes ,

    Something like (assuming the table and toggle name here)

    Filter(
     Table1,
     'Open/Closed' = 
     If(
     Toggle1.Value,
     "Open",
     "Closed"
     )
    )

     where the "on" is Open and the "off" is closed.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • Verified answer
    poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @jeremywoakes 

     

    First I recommend strongly change the name of the column to OpenClosed  in Excel File, delete and recreate the data source. There may be a problem if having the Slash / in column name.

     

    Then, try something like this and it should work:

     

    1) Place a data table on the canvas to test it. Suppose it is called DataTable2  for this example.

     

    1b) Select a couple fields so you can see the data table columns - to do this click on "Edit Fields" on the right side, and select some fields you want - such as OpenClosed field and Client field for example. If having trouble, go to the tree view, select DataTable2 first from the tree view, then try again from the right side.

     

    2) In Items Property of the data table (suppose it is called DataTable2  for this example) put this: 

     

     

     

     

    Filter(Table1,OpenClosed=VarOpenClosed)

     

     

     

     

    3) Place a Toggle property on the canvas. Suppose it is called Toggle1 for this example.

     

    4) (Optional) Regarding Toggle1 - > for the Properties:

     TrueText

    put "Open"

    and

    FalseText

    put "Closed"

     

    5) For Screen1 (the first screen) OnVisible property (the OnVisible property of Screen1) put this:

     

     

     

     

    Set(VarOpenClosed,"Open")

     

     

     

     

    6) For  the Default property of Toggle1 put

     

     

     

    true
    

     

     

     

     

    7) For OnChange property of Toggle1 

    put

     

     

     

    If(Self.Value=true,Set(VarOpenClosed,"Open"),Set(VarOpenClosed,"Closed"))

     

     

     

     

    😎 😎 Try the app.

     

    pl21--81121-sample.gif

     

     

    I have also attached a working sample msapp file pl2_8-11-2021.msapp if you would like to import a full, working example yourself for your convenience.

     

    To use the sample msapp attached, follow these steps:

     

    1) Download the msapp file attached to this post, to Desktop or a folder of your choice, by clicking on it from this post.

    2) Create a new, blank Power App Canvas App

    3) Go to File -> Open -> Browse

    81121-poa-01.png

     

    4) Navigate to location of .msapp file from Step 1, select it, and press the "Open" button.

    5) The working example msapp file should load

    6) Note, the msapp file will come in without the connector (intentionally). You'll need to set up the Excel Online (business) connector and hook it to your sample excel file to see the sample app I made fully working

    7) After step 6, you can try previewing the app and using the Toggle, and it should show Open cases only, or Closed cases only.

     

    Check if it helps.

     

     

  • Verified answer
    Irfan Profile Picture
    164 on at

    Hi,


    OnCheck of your toggle button:

    ClearCollect(collAllItems,Filter(Table1,'Open/Closed'="Open"))

    Irfan_0-1628741917503.png

     



    OnUnCheck of your toggle button:
    ClearCollect(collAllItems,Filter(Table1,'Open/Closed'="Closed"))

    Irfan_1-1628741937262.png

     

     

     

    In your gallery/datatable, use the the collection collAllItems as your source

    Irfan_2-1628741957816.png

     

     

    Open

    Irfan_3-1628741987120.png

     

    Closed

    Irfan_4-1628742003048.png

     

    Please mark it as solved if this solves your issue.

    Thanks.

    -Irfan

  • Verified answer
    jeremywoakes Profile Picture
    29 on at

    Thank you very much, greatly appreciated.

  • Verified answer
    jeremywoakes Profile Picture
    29 on at

    Wow, incredible. Thank you very much.

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 345 Most Valuable Professional

#2
11manish Profile Picture

11manish 207 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 177

Last 30 days Overall leaderboard