cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Impactful Individual
Impactful Individual

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
Impactful Individual
Impactful Individual

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
Impactful Individual
Impactful Individual

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (7,503)