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

Gallery Filtering - Checkbox and Textfields

Hi all,

 

Some help needed please.

 

I have a gallery linked with a collection from an SP list. i am trying to add a few filtering options based on a Check Box value=true but nothing is working as it should.

 

Here is the basic filter code;

SortByColumns(Filter([@TAXICOL],StartsWith(StaffName, Name1.Text)),"DateReq", If(SortDescending1, Descending, Ascending))

 

Here is the filter code that allows me to filter based on checkbox, but the gallery doesn't show any items that does not have the value stipulated by the true statement of the checkbox;

SortByColumns(Filter([@TAXICOL],StartsWith(StaffName, Name1.Text),If(BookedYN.Value=true,Booked,"Yes")),"DateReq", If(SortDescending1, Descending, Ascending))

 

I also need a similar thing to the below code on a similar gallery but nothing works;

SortByColumns(Filter([@TAXICOL], TextSearchBox1_1.Text in StaffName || TextSearchBox1_1.Text in Schedule1 || TextSearchBox1_1.Text in Schedule2 || TextSearchBox1_1.Text in Schedule3), "DateReq", If(SortDescending2, Ascending, Descending))

4 REPLIES 4
Super User II
Super User II

Hi @VegetA3113 

You can use this formula for the items property of the gallery.

 

With({txc: If(
               BookedYN, Filter(
                                [@TAXICOL],Booked="Yes"
                          ),
                          [[@TAXICOL]
             )},
    SortByColumns(
                   Filter(
                           txc,StartsWith(
                                           StaffName,Name1.Text
                                )
                     ),"DateReq", 
                       If(
                           SortDescending1, Descending, Ascending
                        )
     )
)

 

This formula starts by creating a temporary table (txc) that is either filtered or not depending on the checkbox status.  Since BookedYN is either true or false, no If() statement is required. 

The temporary table is then used in the subsequent filter and sort.   

With respect to your second issue, I have no idea what you mean by a "similar thing". 

Thanik you for your reply.

 

I actuially managed to get mine to work.

 

I did try the code but it had quite a few red squiggles, I tweaked it to this, the only error now is the bold =;

 

With({txc:If(BookedYN_2.Value=true, Filter(TAXICOL,Booked="Yes"),TAXICOL)}, SortByColumns( Filter( txc,StartsWith(StaffName,Name1_2.Text)),"DateReq",If( SortDescending1, Descending, Ascending)))

Super User II
Super User II

@VegetA3113 

A checkbox is either true or false.  If you are storing your data in some other way, ie. "Yes" instead of true, you will get errors.  While you didn't mention it, if your column type is Yes/No, it causes problems, to simplify, make it a single line of text (SLOT) instead and store the actual value provided by the checkbox. The only column types that I use in SharePoint are SLOT, date/time and numbers.  The rest cause problems in PowerApps and work-arounds are required. 

Ok understood.

 

I have changed the SP column as you stated and the values are now true or false instead of yes/no. The code still shows many squiggly red error lines though.

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (85,345)