web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Syntax for SortbyColum...
Power Apps
Answered

Syntax for SortbyColumns/Search/Filter

(0) ShareShare
ReportReport
Posted on by 235

Hi - I have an app that is now getting a lot of data in the main screen, and I want to add a combo box so the user can filter by a certain customer. On a different screen in the app I have this same setup, except is also includes a textbox where the user can also filter on a name. We also have different levels of security based on whether the user is an approver or not. This is controlled by a global variable like so:

GraemeNZ_0-1653611833652.png

or for a customer:

GraemeNZ_1-1653611866262.png

 

I'm getting lost in the syntax for what I think is an easy change...

 

For the gallery that works, I have this:

//If current user is approver show all, else filter the data based on the customer logged in
SortByColumns(
  Search(
    Filter(
      'Master Ingredients List',
      If(
        gvCurrentUser = "FIW Approver",
        If(IsBlank(cbCustFilter_Ing.Selected.Value),
          true,
          Customer.Value = cbCustFilter_Ing.Selected.Value
        ),
        Customer.Value = gvCustomer
      )
    ),
    TxtIngFilter.Text,
    "Title"
  ),
  "Title",
  Ascending
)

 

I have created a new combo box named cbCustFilter_IngEntry, and I want to remove the TxtIngFilter.Text bit, so I tried this but the syntax is wrong and I can't see how...

 

//If current user is approver show all, else filter the data based on the customer logged in
SortByColumns(
  Search(
    Filter(
      'Master Ingredients List',
      If(
        gvCurrentUser = "FIW Approver",
        If(IsBlank(cbCustFilter_Ing.Selected.Value),
          true,
          Customer.Value = cbCustFilter_IngEntry.Selected.Value
        ),
        Customer.Value = gvCustomer
      )
      ),
    "Title",
    Ascending
)

 

Cheers, GraemeNZ

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    154,953 Most Valuable Professional on at

    Hi @GraemeNZ ,

    You still have Search in the top of the second one, but nothing to search. You can also trim the code down and get rid of Delegation issues

    SortByColumns(
     Filter(
     'Master Ingredients List',
     (
     gvCurrentUser = "FIW Approver" &&
     Customer.Value = gvCustomer
     ) ||
     (
     IsBlank(cbCustFilter_Ing.Selected.Value) ||
     Customer.Value = cbCustFilter_IngEntry.Selected.Value
     )
     ),
     "Title",
     Ascending
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • GraemeNZ Profile Picture
    235 on at

    Thanks @WarrenBelz , I completely forgot to remove the Search. Doh.

     

    I'm not sure that your suggested formula does what the old one does. The old code checks if the current user is an approver, and if so they can see all items, or if they select a customer from the combo they will only see that customer's items. If the user is not an approver, then they can only see their own items.

     

    Your suggested code looks like it says if the user is an approver, then only display the items where the customer value is blank. If you look at my screenshots in my first post, if gvCurrentUser is FIW Approver, then gvCustomer is blank. Then I get lost as to what the second part does...

     

    But nevermind, you helped me with my syntax and it works 🙂 , and I'm not expecting to have a large data set, as there are likely to be less than 500 items in here.

     

    Cheers, GraemeNZ

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 514

#2
WarrenBelz Profile Picture

WarrenBelz 419 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 295

Last 30 days Overall leaderboard