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 / Nested sorting functio...
Power Apps
Answered

Nested sorting functions interlocking, gallery filtering function issues.

(0) ShareShare
ReportReport
Posted on by 81

Dear Power Apps Community,

 

Following code is used to filter a Gallery:

 Sort(
 Search(
 AddColumns(
 Filter(
 JOBIO_DATA;
 JOB_STATUS.Value = "Not Started";
 IsBlank(cboLocation.SelectedItems.Value) || IsEmpty(cboLocation.SelectedItems.Value) || JOB_LOCATION.Value = cboLocation.Selected.Value;
 IsBlank(cboWho.SelectedItems.Value) || IsEmpty(cboWho.SelectedItems.Value) || JOB_WHO.Value = cboWho.Selected.Value;
 IsBlank(cboPrio.SelectedItems.Value) || IsEmpty(cboPrio.SelectedItems.Value) || JOB_PRIORITY.Value = cboPrio.Selected.Value;
 IsBlank(cboParts.SelectedItems.Value) || IsEmpty(cboParts.SelectedItems.Value) || JOB_PARTS_PRESENT.Value = cboParts.Selected.Value
 );
 "IDcopy";
 Text('Id (ID)')
 );
 txtSearchBox.Text;
 "JOB_SHORT_DESCRIPTION";
 "IDcopy"
 );
 JOB_SHORT_DESCRIPTION;
 Switch(
 varShortDescriptionStart;
 0;
 SortOrder.Ascending;
 1;
 SortOrder.Descending;
 2;
 SortOrder.PROBLEM
 )
 );
 JOB_DATUM_AANGEMAAKT;
 Switch(
 varDateAddedStart;
 0;
 SortOrder.Ascending;
 1;
 SortOrder.Descending;
 2;
 SortOrder.PROBLEM

 )
 );
 JOB_PRIORITY.Value;
 SortOrder.Ascending
)

The issue: I'm using two switch functions that change the SortOrder to Ascending/Descending depending on the value of a variable (set by a button). I would like to third, neutral, option where the Sort function is not used. 

For example:

 

Switch(
varShortDescriptionStart;
0;
SortOrder.Ascending;
1;
SortOrder.Descending;
2;
Neutral position, specific column is not being sorted for anything
)

 

The reason I want this neutral position is because the functions are interlocking. For example once one of the two variables sorts the gallery on date added, the other alfabetically, once I sort on date added the alfabetical one has no influence anymore.

 

Any ideas?

 

Kind regards,

 

Sébastien

Categories:
I have the same question (0)
  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @PonceletSeba ,

     

    Please try:

    		With(
    		 {searchTable:
     Search(
     AddColumns(
     Filter(
     JOBIO_DATA;
     JOB_STATUS.Value = "Not Started";
     IsBlank(cboLocation.SelectedItems.Value) || IsEmpty(cboLocation.SelectedItems.Value) || JOB_LOCATION.Value = cboLocation.Selected.Value;
     IsBlank(cboWho.SelectedItems.Value) || IsEmpty(cboWho.SelectedItems.Value) || JOB_WHO.Value = cboWho.Selected.Value;
     IsBlank(cboPrio.SelectedItems.Value) || IsEmpty(cboPrio.SelectedItems.Value) || JOB_PRIORITY.Value = cboPrio.Selected.Value;
     IsBlank(cboParts.SelectedItems.Value) || IsEmpty(cboParts.SelectedItems.Value) || JOB_PARTS_PRESENT.Value = cboParts.Selected.Value
     );
     "IDcopy";
     Text('Id (ID)')
     );
     txtSearchBox.Text;
     "JOB_SHORT_DESCRIPTION";
     "IDcopy"
     )};
     Switch(
     varShortDescriptionStart;
     0;
     Sort(searchTable;JOB_SHORT_DESCRIPTION;SortOrder.Ascending);
     1;
     Sort(searchTable;JOB_SHORT_DESCRIPTION;SortOrder.Descending);
     2;
     searchTable
     )
     );

     

    Best Regards,
    Bof

  • PonceletSeba Profile Picture
    81 on at

    Hi,

     

    Thanks for your suggestion, but I noticed there are a few important parts left out in your code snippet. I'm using 2 switch functions since I have two variables, also the priority of sorting I gave in my code snipped (First on priority) is also important to me.

    Thanks nonetheless,

     

    Sébastien

  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @PonceletSeba ,

     

    Because you didn't provide the full formula. But the principle is the same, you can apply a similar method to the external sort.

    vbofengmsft_0-1692346049672.png

     

    Best Regards,

    Bof

     

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