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 / Please help! Sorting a...
Power Apps
Unanswered

Please help! Sorting a lookup text column

(0) ShareShare
ReportReport
Posted on by

I've set up a gallery called 'All-Projects,' which currently displays both project names and program names in its view. The project names are sourced from the Projects table, while the program names are drawn from the Program table. The program name is a lookup text column in my projects table.

Currently, the Items property of my 'All-Projects' gallery is defined as follows: 'msdyn_subject' is the primary text column, displayed as 'Name' from the Projects table, and 'cr155_projectpriority' is a whole number column displayed as 'Project Priority #'.

The existing code effectively sorts project names alphabetically and project priorities numerically. However, I'm also aiming to sort program names alphabetically. I came across some forum posts mentioning the use of the AddColumn function, but I'm uncertain about its implementation within my current code. Any assistance would be greatly appreciated. Thank you.



 

Switch(
 varSortColumn,
 "msdyn_subject",
 SortByColumns(
 Filter(
 Projects,
 (varSortColumn = "msdyn_subject" || (
 'Project Status (cr420_projectstatus)' = 'Project Status'.Active ||
 'Project Status (cr420_projectstatus)' = 'Project Status'.Cancelled ||
 'Project Status (cr420_projectstatus)' = 'Project Status'.Paused ||
 'Project Status (cr420_projectstatus)' = 'Project Status'.Closed
 )) &&
 (
 Len(cmbProjectStatusFilters.Selected.Value) = 0 ||
 'Project Status (cr420_projectstatus)' in cmbProjectStatusFilters.SelectedItems.Value
 ) &&
 (
 Len(cmbDepartmentFilter_2.Selected.'Division Name') = 0 // Division filter condition
 || Division.'Division Name' in cmbDepartmentFilter_2.SelectedItems.'Division Name'
 ) &&
 (
 Len(cmbDepartmentFilter_3.Selected.'Department Name') = 0 // Division filter condition
 || Department.'Department Name' in cmbDepartmentFilter_3.SelectedItems.'Department Name'
 ) &&
 (
 'inpHomeBrsScr-Search'.Text in Name ||
 StartsWith('Project manager'.'Full Name', 'inpHomeBrsScr-Search'.Text) ||
 EndsWith('Created By'.'Full Name', 'inpHomeBrsScr-Search'.Text)
 )
 ),
 "msdyn_subject",
 If(
 varSortDirection = SortOrder.Ascending,
 SortOrder.Descending,
 SortOrder.Ascending
 )
 ),
 SortByColumns(
 Filter(
 Projects,
 (('Project Status (cr420_projectstatus)' = 'Project Status'.Active ||
 'Project Status (cr420_projectstatus)' = 'Project Status'.Cancelled ||
 'Project Status (cr420_projectstatus)' = 'Project Status'.Paused ||
 'Project Status (cr420_projectstatus)' = 'Project Status'.Closed)) &&
 (
 Len(cmbProjectStatusFilters.Selected.Value) = 0 ||
 'Project Status (cr420_projectstatus)' in cmbProjectStatusFilters.SelectedItems.Value
 ) &&
 (
 Len(cmbDepartmentFilter_2.Selected.'Division Name') = 0 // Division filter condition
 || Division.'Division Name' in cmbDepartmentFilter_2.SelectedItems.'Division Name'
 ) &&
 (
 Len(cmbDepartmentFilter_3.Selected.'Department Name') = 0 // Division filter condition
 || Department.'Department Name' in cmbDepartmentFilter_3.SelectedItems.'Department Name'
 ) &&
 (
 'inpHomeBrsScr-Search'.Text in Name ||
 StartsWith('Project manager'.'Full Name', 'inpHomeBrsScr-Search'.Text) ||
 EndsWith('Created By'.'Full Name', 'inpHomeBrsScr-Search'.Text)
 )
 ),
 "cr155_projectpriority",
 If(
 varSortDirection = SortOrder.Ascending,
 SortOrder.Descending,
 SortOrder.Ascending
 )
 )
)

 

 

Categories:
I have the same question (0)

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

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 387

#2
timl Profile Picture

timl 340 Super User 2026 Season 1

#3
Vish WR Profile Picture

Vish WR 301

Last 30 days Overall leaderboard