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
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,851)