Search code examples
powerapps

Power Apps Sort Filter & Search


I am having an issue combining a function in a power app I am building. Each of the following statements work fine independently.

SortByColumns(
    If(Dropdown1.Selected.Status = "All", UAR_Access, 
        Filter(UAR_Access, Status = Dropdown1.Selected.Status)), 
   "LAST_x0020_NAME",
    If(srtDescending,
        Descending,
        Ascending))

and

Search(UAR_Access, Search_Txt.Text,"LAST_x0020_NAME", "FIRST_x0020_NAME")

My issue comes into play where I want to apply both statements to the same gallery. I am sure it can be done, I need some help with the syntax. Thanks in advance!


Solution

  • Both Filter and Search functions take and return a table, so they can be combined such that the result of one can be used as the parameter to the other, like in the example below:

    SortByColumns(
        Search(
            If(
                Dropdown1.Selected.Status = "All",
                UAR_Access,
                Filter(UAR_Access, Status = Dropdown1.Selected.Status)),
            Search_Txt.Text,
            "LAST_x0020_NAME", "FIRST_x0020_NAME"),
       "LAST_x0020_NAME",
        If(srtDescending, SortOrder.Descending, SortOrder.Ascending))