cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Toggle Button - Filter

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. 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Resolver I
Resolver I

Re: Toggle Button - Filter

@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

View solution in original post

9 REPLIES 9
Highlighted
Resolver I
Resolver I

Re: Toggle Button - Filter

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

Highlighted
Frequent Visitor

Re: Toggle Button - Filter

Hi @JimmyBecks ,

 

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

Highlighted
Resolver I
Resolver I

Re: Toggle Button - Filter

@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)

 

 

Highlighted
Community Support
Community Support

Re: Toggle Button - Filter

Hi @JV_DXB ,

 

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

Do you test with @JimmyBecks '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

Highlighted
Frequent Visitor

Re: Toggle Button - Filter

Hello,

I have tried the below code as guided by @JimmyBecks  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)))

Highlighted
Community Support
Community Support

Re: Toggle Button - Filter

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

Highlighted
Frequent Visitor

Re: Toggle Button - Filter

@JimmyBecks @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)))

Highlighted
Resolver I
Resolver I

Re: Toggle Button - Filter

@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

View solution in original post

Highlighted
Frequent Visitor

Re: Toggle Button - Filter

@JimmyBecks 

 

Worked. Thanks.

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,858)