Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building 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:
  • Verified answer
    v-bofeng-msft Profile Picture
    on at
    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 at
    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 at
    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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,668 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard