cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
serviceflow
Helper I
Helper I

Sort Dropdown Populating from Collection

We have an employee directory app that pulls from O365 Users and Azure AD to populate a collection, In a filter screen we have 'Department_1' dropdwon where the values populate from the collection "ColActiveusers". We simply want to custom sort these values in the dropdown i a specific order. Below is the code currently applied to the dropdown values and as you can see we have omitted some values but can't figure out how to apply a custom sort to them.  

 

Sort(
Distinct(
Filter(
ColActiveUsers,
!IsBlank(Department),
Department <> "BU5",
Department <> "BU4",
Department <> "BU7",
Department <> "BU8",
Department <> "Maintenance",
Department <> "Receiving",
Department <> "BU 1",
Department <> "Plant 1-8",
Department <> "Industrial Sales",
Department <> "NHI",
Department <> "Division 259, 314",
Department <> "Division Welformed, Industrial Sales and Marketing"
),
Department
),
Result
)

 

 

 

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
v-qiaqi-msft
Community Support
Community Support

Hi @serviceflow,

Have you solved your problem?

Could you please tell me what sort order you want to apply on the Department?

 

In addition to sorting ascending or descending, SortByColumns can sort based on a single column table of values. For example, you can sort record based on the name of a day of the week by supplying [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ] as the sort order.

All records which have Monday" will come first, followed by Tuesday, and so on. Records found that do not appear in the sort table are put at the end of the list.

 

So if you want to sort the Department by a special order, you could write a table like the above format:

SortByColumns(
Distinct(
Filter(
ColActiveUsers,
!IsBlank(Department),
Department <> "BU5",
Department <> "BU4",
Department <> "BU7",
Department <> "BU8",
Department <> "Maintenance",
Department <> "Receiving",
Department <> "BU 1",
Department <> "Plant 1-8",
Department <> "Industrial Sales",
Department <> "NHI",
Department <> "Division 259, 314",
Department <> "Division Welformed, Industrial Sales and Marketing"
),
Department
),
[ Department1, Department2,Department3,... ]
)
Best Regards,
Qi

View solution in original post

2 REPLIES 2
Scott_Parker
Resolver III
Resolver III

It would be helpful to know more about what you are looking for in your "custom sort". I'm assuming Ascending and Descending aren't good enough. You may want to use AddColumns to define your custom logic in a separate column (say, outputting an integer), sort your table with the help of that column, and then DropColumns to remove it when finished sorting.

v-qiaqi-msft
Community Support
Community Support

Hi @serviceflow,

Have you solved your problem?

Could you please tell me what sort order you want to apply on the Department?

 

In addition to sorting ascending or descending, SortByColumns can sort based on a single column table of values. For example, you can sort record based on the name of a day of the week by supplying [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ] as the sort order.

All records which have Monday" will come first, followed by Tuesday, and so on. Records found that do not appear in the sort table are put at the end of the list.

 

So if you want to sort the Department by a special order, you could write a table like the above format:

SortByColumns(
Distinct(
Filter(
ColActiveUsers,
!IsBlank(Department),
Department <> "BU5",
Department <> "BU4",
Department <> "BU7",
Department <> "BU8",
Department <> "Maintenance",
Department <> "Receiving",
Department <> "BU 1",
Department <> "Plant 1-8",
Department <> "Industrial Sales",
Department <> "NHI",
Department <> "Division 259, 314",
Department <> "Division Welformed, Industrial Sales and Marketing"
),
Department
),
[ Department1, Department2,Department3,... ]
)
Best Regards,
Qi

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (2,584)