cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
hurs0047
Frequent Visitor

Search Box - Sorting & Filtering From ListBox

I am using a ListBox to search a column in a sharpoint list which works but I would like to be able to Sort and Filter the Browse Gallery Created. 

 

I am using this formula in the item for the gallery.

 

If("Gagnon" in SelectListBox.SelectedItems.Value, Search('Progress Test 2', "PBGAGNINSL", "resource_code_list"), "Brand" in SelectListBox.SelectedItems.Value, Search('Progress Test 2', "PBBRNDSCAF", "resource_code_list"), "Vics" in SelectListBox.SelectedItems.Value, Search('Progress Test 2', "PBVCH1EQOP", "resource_code_list"))

 

Gagnon, Brand and Vics being my choices on the list box.  Let me know if this is possible or if I should be trying to come at this a different way.

1 ACCEPTED SOLUTION

Accepted Solutions
CarlosFigueira
Power Apps
Power Apps

You should be able to apply Filter/SortByColumns to the result of your expression. For example, if you have this expression (which I believe is equivalent to yours):

Search(
    'Progress Test 2',
    If(
        "Gagnon" in SelectListBox.SelectedItems.Value, "PBGAGNINSL",
        "Brand" in SelectListBox.SelectedItems.Value, "PBBRNDSCAF",
        "Vics" in SelectListBox.SelectedItems.Value, "PBVCH1EQOP",
        "")
    "resource_code_list")

Then you can apply an additional filter either in the original data source ('Progress Test 2') or in the result of the Search function. For example, this below shows the former:

Filter(
    Search(
        'Progress Test 2',
        If(
            "Gagnon" in SelectListBox.SelectedItems.Value, "PBGAGNINSL",
            "Brand" in SelectListBox.SelectedItems.Value, "PBBRNDSCAF",
            "Vics" in SelectListBox.SelectedItems.Value, "PBVCH1EQOP",
            "")
        "resource_code_list"),
    AnotherColumn > Value(ValueTextInput))

Or inside the Search function:

Search(
    Filter('Progress Test 2', AnotherColumn > Value(ValueTextInput.Text)),
    If(
        "Gagnon" in SelectListBox.SelectedItems.Value, "PBGAGNINSL",
        "Brand" in SelectListBox.SelectedItems.Value, "PBBRNDSCAF",
        "Vics" in SelectListBox.SelectedItems.Value, "PBVCH1EQOP",
        "")
    "resource_code_list")

And you can use the SortByColumns on the result of the combined Filter/Search expression, like in the example below:

SortByColumns(
    Search(
        Filter('Progress Test 2', AnotherColumn > Value(ValueTextInput.Text)),
        If(
            "Gagnon" in SelectListBox.SelectedItems.Value, "PBGAGNINSL",
            "Brand" in SelectListBox.SelectedItems.Value, "PBBRNDSCAF",
            "Vics" in SelectListBox.SelectedItems.Value, "PBVCH1EQOP",
            "")
        "resource_code_list"),
    "ColumnToSort",
    Descending)

View solution in original post

1 REPLY 1
CarlosFigueira
Power Apps
Power Apps

You should be able to apply Filter/SortByColumns to the result of your expression. For example, if you have this expression (which I believe is equivalent to yours):

Search(
    'Progress Test 2',
    If(
        "Gagnon" in SelectListBox.SelectedItems.Value, "PBGAGNINSL",
        "Brand" in SelectListBox.SelectedItems.Value, "PBBRNDSCAF",
        "Vics" in SelectListBox.SelectedItems.Value, "PBVCH1EQOP",
        "")
    "resource_code_list")

Then you can apply an additional filter either in the original data source ('Progress Test 2') or in the result of the Search function. For example, this below shows the former:

Filter(
    Search(
        'Progress Test 2',
        If(
            "Gagnon" in SelectListBox.SelectedItems.Value, "PBGAGNINSL",
            "Brand" in SelectListBox.SelectedItems.Value, "PBBRNDSCAF",
            "Vics" in SelectListBox.SelectedItems.Value, "PBVCH1EQOP",
            "")
        "resource_code_list"),
    AnotherColumn > Value(ValueTextInput))

Or inside the Search function:

Search(
    Filter('Progress Test 2', AnotherColumn > Value(ValueTextInput.Text)),
    If(
        "Gagnon" in SelectListBox.SelectedItems.Value, "PBGAGNINSL",
        "Brand" in SelectListBox.SelectedItems.Value, "PBBRNDSCAF",
        "Vics" in SelectListBox.SelectedItems.Value, "PBVCH1EQOP",
        "")
    "resource_code_list")

And you can use the SortByColumns on the result of the combined Filter/Search expression, like in the example below:

SortByColumns(
    Search(
        Filter('Progress Test 2', AnotherColumn > Value(ValueTextInput.Text)),
        If(
            "Gagnon" in SelectListBox.SelectedItems.Value, "PBGAGNINSL",
            "Brand" in SelectListBox.SelectedItems.Value, "PBBRNDSCAF",
            "Vics" in SelectListBox.SelectedItems.Value, "PBVCH1EQOP",
            "")
        "resource_code_list"),
    "ColumnToSort",
    Descending)

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.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

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
Users online (3,307)