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 / Needing some help in P...
Power Apps
Answered

Needing some help in PowerApps "SortByColumns" syntax‌ :)

(0) ShareShare
ReportReport
Posted on by 8

Hi, I am trying to build an application from a MSSQL server source. I have to filter the fields of a gallery and, the filtering options consist of 5 text boxes and two combo boxes. I am using the structure below but, although the syntax is correct it only filters when I type in the first text box. 

PS: You will notice that although I have spoken of combo boxes there is nothing that makes reference to them in the code. If someone could tell me how to incorporate them correctly I would also appreciate it, since I see that the syntax has been changing over time in the application and I have not found current documentation about it.

 

The code:

 

SortByColumns(
    Filter(
        'DATASOURCE';
        StartsWith(SQLFIELD1; Entidad.Text);
        StartsWith(SQLFIELD2; Familia.Text);
        StartsWith(SQLFIELD3; Empleador.Text);
        StartsWith(SQLFIELD4; Patologías.Text);
        StartsWith(SQLFIELD5; Dirección.Text)

    );
    "SQLFIELD1"; SortOrder.Ascending;
    "SQLFIELD2"; SortOrder.Ascending;
    "SQLFIELD3"; SortOrder.Ascending;
    "SQLFIELD4"; SortOrder.Ascending;
    "SQLFIELD5"; SortOrder.Ascending
)

 

Thank you very much in advance!

Categories:
I have the same question (0)
  • Verified answer
    timl Profile Picture
    37,283 Super User 2026 Season 2 on at

    Hi @ogarrii 

    The syntax you use would look like this:

    SortByColumns(
     Filter(
     'DATASOURCE';
     StartsWith(SQLFIELD1; Entidad.Text) || IsBlank(Entidad.Text);
     StartsWith(SQLFIELD2; Familia.Text) || IsBlank(Familia.Text);
     StartsWith(SQLFIELD3; Empleador.Text) || IsBlank(Empleador.Text);
     StartsWith(SQLFIELD4; cboPatologías.Selected.Value) || IsBlank(cboPatologías.Selected);
     StartsWith(SQLFIELD5; cboDirección.Selected.Value) || IsBlank(cboDirección.Selected)
    
     );
     "SQLFIELD1"; SortOrder.Ascending;
     "SQLFIELD2"; SortOrder.Ascending;
     "SQLFIELD3"; SortOrder.Ascending;
     "SQLFIELD4"; SortOrder.Ascending;
     "SQLFIELD5"; SortOrder.Ascending
    )

     

    This assumes that cboPatologías and cboDirección are CombBox controls. Note that you would have to replace the .Value identifier with the name of the database column that you want to reference.

     

  • johnnylo Profile Picture
    20 on at

    Is Semi-colon an acceptable character?  I thought in SortByColumns comma should be used for seperate the sort columns and options?

     

  • timl Profile Picture
    37,283 Super User 2026 Season 2 on at

    @johnnylo - this question relates to Power Apps in Spanish. In Spanish, semi-colon is the character that's used to separate the sort column options.

    I'm guessing you're using English so in your case, comma is the correct character.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 396 Most Valuable Professional

#2
11manish Profile Picture

11manish 134 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 101 Super User 2026 Season 2

Last 30 days Overall leaderboard