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

Community site session details

Session Id : dE5JePpcGcwxGY/ijheFaZ
Power Apps - Building Power Apps
Answered

Nested sorting functions interlocking, gallery filtering function issues.

Like (0) ShareShare
ReportReport
Posted on 17 Aug 2023 12:41:12 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)
  • Verified answer
    v-bofeng-msft Profile Picture
    on 18 Aug 2023 at 08:09:08
    Re: Nested sorting functions interlocking, gallery filtering function issues.

    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

     

  • PonceletSeba Profile Picture
    81 on 18 Aug 2023 at 06:45:47
    Re: Nested sorting functions interlocking, gallery filtering function issues.

    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

  • v-bofeng-msft Profile Picture
    on 18 Aug 2023 at 01:36:28
    Re: Nested sorting functions interlocking, gallery filtering function issues.

    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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

MS.Ragavendar – Community Spotlight

We are honored to recognize Ragavendar Swaminatha Subramanian as our September…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 982 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 396 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 356

Last 30 days Overall leaderboard
Loading complete