cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Skilled Sharer
Skilled Sharer

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
Highlighted
Skilled Sharer
Skilled Sharer

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
Highlighted
Skilled Sharer
Skilled Sharer

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
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!

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