cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
WillPage
Level 8

Filtering a gallery by more than one field based on a variable

I have a gallery with the items property set like this:

SortByColumns(
    Filter(
        'Bookings',
        StartsWith(
            Title,
            TextSearchBox1.Text
        ), If(ShowOld1, 'Departure Date' <= Today(), 'Departure Date' > Today ())
    ),
    "Arrival_x0020_Date",
    If(
        SortDescending1,
        Descending,
        Ascending
    )
)

There's a button with OnSelect that does UpdateContext({ShowOld1: !ShowOld1}) 

 

This works well - I can toggle between past bookings and future bookings (I know the name of the variable is misleading, ShowOld1 = true actually shows future departures).

 

I want to extend the function of this button to include a filter by another column, Status.

 

Status can be many things, including Declined or Cancelled. How can I use the boolean context ShowOld1 to toggle the gallery items between these two states:

 

1. Future bookings with status that is not Cancelled or Declined

2. Past bookings with any status, and future bookings with status Cancelled or Declined.

 

Any help greatly appreaciated.

1 ACCEPTED SOLUTION

Accepted Solutions
WillPage
Level 8

Re: Filtering a gallery by more than one field based on a variable

II have solved it myself like this:

SortByColumns(
    Filter(
        'Bookings',
        StartsWith(
            Title,
            TextSearchBox1.Text
        ),
        If(
            ShowOld1,
            'Departure Date' <= Today() || Status = "Declined" || Status = "Cancelled",
            'Departure Date' > Today () && Status <> "Declined" && Status <> "Cancelled"
        )
    ),
    "Arrival_x0020_Date",
    If(
        SortDescending1,
        Descending,
        Ascending
    )
)

View solution in original post

1 REPLY 1
WillPage
Level 8

Re: Filtering a gallery by more than one field based on a variable

II have solved it myself like this:

SortByColumns(
    Filter(
        'Bookings',
        StartsWith(
            Title,
            TextSearchBox1.Text
        ),
        If(
            ShowOld1,
            'Departure Date' <= Today() || Status = "Declined" || Status = "Cancelled",
            'Departure Date' > Today () && Status <> "Declined" && Status <> "Cancelled"
        )
    ),
    "Arrival_x0020_Date",
    If(
        SortDescending1,
        Descending,
        Ascending
    )
)

View solution in original post

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (5,049)