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

Need help combining code please.

I'm building an app with a search field that has both button filter and dropdown option filter capabilities. 

My idea is based off of this tutorial: https://www.linkedin.com/pulse/powerapps-tracking-app-tutorial-richard-burdes

 

Button Filters: "PO Received", "Order Processed", "Over 15 Days", "Order Shipped", "Show All"

Dropdown Filters: "All", "Customer", "PO#", "Sales Rep", "Purchaser"

 

The following code works for me, but I can't figure out how to combine them.

 

1. The button filters work with the code below:

If(
    con_Status = "Show All",
    SortByColumns(
        Filter(
            POCollection,
            'Order Status'.Value <> "CANCELLED" 
        ),
        "Date",
        Ascending
    ),
    SortByColumns(
        Filter(
            POCollection,
            If(con_Status = "Show All", false,
            'Order Status'.Value in Split(
                con_Status,
                ","
            ).Result, true)
        ),"Date",Ascending))

 

2. The Dropdown filters work with the code below:

If(
    cbSearchFilter.SelectedText.Value = "All",
    Filter(
        POCollection,
        searchQuery in 'Date Received' || searchQuery in Customer || searchQuery in Title || searchQuery in 'PO Total' || searchQuery in 'Quote #' || searchQuery in 'Sales Rep'.Value || searchQuery in 'Assigned Purchaser'.Value
    ),
    If(
        cbSearchFilter.SelectedText.Value = "Customer",
        Filter(
            POCollection,
            searchQuery in Customer
        ),
        If(
            cbSearchFilter.SelectedText.Value = "PO#",
            Filter(
                POCollection,
                searchQuery in Title
            ),
            If(
                cbSearchFilter.SelectedText.Value = "Sales Rep",
                Filter(
                    POCollection,
                    searchQuery in 'Sales Rep'.Value
                ),
                If(
                    cbSearchFilter.SelectedText.Value = "Purchaser",
                    Filter(
                        POCollection,
                        searchQuery in 'Assigned Purchaser'.Value
                    )
                )
            )
        )
    )
)

 

Please help me to combine and possibly simplify these. Thank you!

0 REPLIES 0

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (3,040)