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 / How to apply a SortByC...
Power Apps
Answered

How to apply a SortByColumn to a large function

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I am working on a project to create a search engine for a list in SharePoint.

We have been asked to apply some filters to the search engine. I was able to apply those filters but I am no longer able to SortByColumn, so now the gallery view is no longer sorting when selecting the sort button.

This is how the function looks like right now:

If(
IsBlank(GenderDropDown.Selected.Result) // && IsBlank(SpecialtyDropDown.Selected.Result)
,Filter('Provider Preference Profile',
StartsWith('Provider Name',TextSearchBox1.Text) || EndsWith('Provider Name', TextSearchBox1.Text)
|| StartsWith(Specialty,TextSearchBox1.Text) || StartsWith(Type1,TextSearchBox1.Text)
|| EndsWith(Language,TextSearchBox1.Text) || StartsWith(Location,TextSearchBox1.Text)),
Filter('Provider Preference Profile',
StartsWith('Provider Name',TextSearchBox1.Text),Gender=GenderDropDown.Selected.Result,Specialty=SpecialtyDropDown.Selected.Result)
)

 

Is there anywhere in this function where I could apply a SortByColumn at? If so, where is the best place to apply it at?

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Your SortByColumns should be around the resultant set of records in this case. 

    I would not recommend using an If Statement in your formula as it doubles the work to keep the formula straight.

    Please consider changing your Formula to the following:

    SortByColumns(
     Filter('Provider Preference Profile',
     (IsBlank(GenderDropDown.Selected.Result) && 
     (
     StartsWith('Provider Name', TextSearchBox1.Text) || EndsWith('Provider Name', TextSearchBox1.Text) || 
     StartsWith(Specialty,TextSearchBox1.Text) || StartsWith(Type1,TextSearchBox1.Text) || 
     EndsWith(Language,TextSearchBox1.Text) || StartsWith(Location,TextSearchBox1.Text) 
     )
     ||
     (!IsBlank(GenderDropdDown.Selected.Result) && StartsWith('Provider Name', TextSearchBox1.Text) && Gender=GenderDropDown.Selected.Result && Specialty=SpecialtyDropDown.Selected.Result)
     )
     ),
     "columnName"
    )

     

    Just replace "columnName" with the column you want to sort by.

     

    I hope this is helpful for you.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you for your response and recommendation.

    I changed my formula with the "columnName" as "Title" but now nothing in the gallery is displaying at all even with both of the dropdowns being empty.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Are you using the same formula I provided - just changed the columnName to Title??

     

    In your original, you had commented out the logic for the SpecialtyDropDrown...is that vital to what you are doing?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Yes, just changed the columnName to Title.

    That was just something I was experimenting with but I'm not currently applying it to my application right now.

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 551

#2
WarrenBelz Profile Picture

WarrenBelz 430 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 298

Last 30 days Overall leaderboard