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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Custom sort order for ...
Power Apps
Unanswered

Custom sort order for phone list (several locations)

(0) ShareShare
ReportReport
Posted on by 315

Hi!
I am creating a phone book for different locations in my company.
When opening the app, people can choose Location 1, Location 2, …


If they choose Location 2, they will enter a Gallery which show the different departments/categories for the location.

 

At the moment these are in a table called «Departments» with the following columns:

- Location

- Department

 

Because I want the first entry of the gallery to be «all numbers» (for every location), I choose to make a collection where I manually create the first entry and then collect the rest of the departments depending on chosen location.

 

I need help with:

Per location there is one data administrator.

How can I create a simple way for the administrator to choose which department will show on top (below All numbers)?

 

I know the following code will give the desired order:

SortByColumns( DataSource, Column, [ " Not Started","In Progress","Approved","Rejected","On Hold " ] ) 


But when different locations have different departments, this will not work.


What is the best solution? Create an extra column in the Departments table called sort number?

Dropdown menu with a choice of numbers for each department?
How can I make sure that 15 different numbers are chosen if a location have 15 different departments?
If two new departments are added and wanted as number 2 / 3, how can we make this happen without having to manually change the numbers of each department?

 

I hope there is a simple solution for this which I do not know about, yet! 🙂

Categories:
I have the same question (0)
  • Ramole Profile Picture
    Super User 2024 Season 1 on at
  • mrstian89 Profile Picture
    315 on at

    Thanks for the repsond, but this does not solve my problem of wanting each location to be able to customize the order of the categories/departments.

  • mrstian89 Profile Picture
    315 on at

    Still not found the solution, but I feel like I am getting closer.

    I have made a ComboBox which includes my categories.

     

    I select my custom order in the combobox, and create a string based on this with the following code:

    With(
     {wString: Char(34) & "All" & Char(34) & "," & Char(34) & Concat(ComboBox1.SelectedItems,Avdeling & Char(34),"," & Char(34))},
     If(Right(wString,1)=",",Left(wString, Len(wString)-1),wString);
     Patch('Phone - Category' , LookUp('Phone - Category', Plant = myPlant),
    { Sortering: wString });Set(Test,wString));

    This gives me the following string:

    "All","Category1","Category10","Category5"

     

    If I use this string directly to sort my Gallery, it works just as I hoped:

    SortByColumns(collectDepartments,"Result", ["All","Category1","Category10","Category5"]) 

     

    But I cannot use it directly, so I have to use it as a variable (get it from a table column).

     

    SortByColumns(collectDepartments,"Result", [SortStringVariable]) 

    When I make the sort order into a variable, it does not sort as expected.
    I believe this is because you cannot sort by a string?

     

    Is there any way that I can use this sort string to sort a gallery?
    I store in in a column in a Dataverse table. 

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard