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 / SortByColumns option f...
Power Apps
Unanswered

SortByColumns option field

(0) ShareShare
ReportReport
Posted on by 16

Hi,

 

in my app I have a gallery with data from a sharepoint list. For sorting and filtering I have created a search box and two dropdown fields as filters like in this video: https://www.youtube.com/watch?v=6KlI1iZ_KD0.

 

This is the list:

screenshot1.png

 

This is the gallery:

screenshot2.png

 

This is the code:

 

SortByColumns(
 Filter(
 'SharePoint List';
 Or(
 Suchleiste.Text in Gegenstand;
 Suchleiste.Text in Kürzel
 ) && (Kategorie.Value = DropdownKategorie.Selected.Value || DropdownKategorie.Selected.Value = Blank()) && (Aufbewahrung.Value = DropdownAufbewahrung.Selected.Value || DropdownAufbewahrung.Selected.Value = Blank ())
 );
 "field_3"
)

 

This works perfectly fine. Right now it is sorted by the "Kürzel" column (The inernal name is "field_3").

But I would like to sort it first by the column "Kategorie" (internal name "field_2") with a custom order and then by "Kürzel. My problem is that "Kategorie" is an option field and I cannot just replace "field_3" with "field_2" in the code above.

 

I tried the AddColumn function:

 

SortByColumns(AddColumns('SharePoint List'; "KategorieSuche"; Kategorie.Value); "KategorieSuche";["Kamera"; "Audio"; "Licht"; "Grip"])

 

This code works on its own but not in conjunction with the code above.

 

Chaining with ";;" does not work either:

 

AddColumns('SharePoint List'; "KategorieSuche"; Kategorie.Value);;

SortByColumns(
 Filter(
 'SharePoint List';
 Or(
 Suchleiste.Text in Gegenstand;
 Suchleiste.Text in Kürzel
 ) && (Kategorie.Value = DropdownKategorie.Selected.Value || DropdownKategorie.Selected.Value = Blank()) && (Aufbewahrung.Value = DropdownAufbewahrung.Selected.Value || DropdownAufbewahrung.Selected.Value = Blank ())
 );
 "KategorieSuche";["Kamera"; "Audio"; "Licht"; "Grip"]
)

 

 

How can I merge these two functions so that I can sort by "Kategorie" while maintaining the filter?

 

I would be very grateful for any help!

 

Elias

 

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

    @elias17 

    AddColumns returns a table with the added column.  It does not alter an existing table!  So the first function in your formula will do nothing.

     

    Please consider changing your Formula to the following:

    SortByColumns(
     Filter(
     AddColumns('SharePoint List'; "KategorieSuche"; Kategorie.Value);
     Or(
     Suchleiste.Text in Gegenstand;
     Suchleiste.Text in Kürzel
     ) && (Kategorie.Value = DropdownKategorie.Selected.Value || DropdownKategorie.Selected.Value = Blank()) && (Aufbewahrung.Value = DropdownAufbewahrung.Selected.Value || DropdownAufbewahrung.Selected.Value = Blank ())
     );
     "KategorieSuche";["Kamera"; "Audio"; "Licht"; "Grip"]
    )

     

    I hope this is helpful for you.

  • elias17 Profile Picture
    16 on at

    Hi @RandyHayes,


    thanks for the explanation. It really helped me understand this better. The code works perfectly!

     

    However I would now like to sort again by "Kürzel". So first the custom sort order by "Kategorie" and then an alphabetical sort by "Kürzel".


    Appending the field doesn't work:

     

     

    SortByColumns(
     Filter(
     AddColumns(
     'SharePoint List';
     "KategorieSuche";
     Kategorie.Value
     );
     Or(
     Suchleiste.Text in Gegenstand;
     Suchleiste.Text in Kürzel
     ) && (Kategorie.Value = DropdownKategorie.Selected.Value || DropdownKategorie.Selected.Value = Blank()) && (Aufbewahrung.Value = DropdownAufbewahrung.Selected.Value || DropdownAufbewahrung.Selected.Value = Blank ())
     );
     "KategorieSuche";
     [
     "Kamera";
     "Audio";
     "Licht";
     "Grip";
     "Elektrizität"
     ];
     "field_3"
    )

     

     

     

    Nesting does not work as well, with this code it just sorts by "Kürzel" only.

     

     

    SortByColumns(
     SortByColumns(
     Filter(
     AddColumns(
     'SharePoint List';
     "KategorieSuche";
     Kategorie.Value
     );
     Or(
     Suchleiste.Text in Gegenstand;
     Suchleiste.Text in Kürzel
     ) && (Kategorie.Value = DropdownKategorie.Selected.Value || DropdownKategorie.Selected.Value = Blank()) && (Aufbewahrung.Value = DropdownAufbewahrung.Selected.Value || DropdownAufbewahrung.Selected.Value = Blank ())
     );
     "KategorieSuche";
     [
     "Kamera";
     "Audio";
     "Licht";
     "Grip";
     "Elektrizität"
     ]
     );
     "field_3"
    )

     

     

     

    I think a similar problem was discussed here: Using Multiple Sort Orders in a Gallery - Power Platform Community

     

    Is there a possible way to achieve this kind of sorting?

     

    Thanks,

    Elias

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
11manish Profile Picture

11manish 394 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 324 Most Valuable Professional

Last 30 days Overall leaderboard