cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mrstian89
Helper III
Helper III

Custom sort order for phone list (several locations)

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! 🙂

3 REPLIES 3
Ramole
Resident Rockstar
Resident Rockstar

Hi @mrstian89 

 

Please check this post https://powerusers.microsoft.com/t5/Building-Power-Apps/Filtering-by-locations-Gallery/m-p/851561 

Thank you
If this post helps, then please consider Accept it as the solution to help the others and consider giving it a "Thumbs Up."
mrstian89
Helper III
Helper III

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
Helper III
Helper III

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. 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power Apps Community Call Jan. 2022 768x460.png

Power Apps Community Call

Please join us on Wednesday, January 19th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,340)