cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
zmansuri
Super User
Super User

Need help with sorting people column

10.png

Above is my gallery.

Below is my item property code:

SortByColumns(
If(
!IsBlank(SearchBox.Text),
Search(
Filter(
Candidate_Leads,
OfficeLoacation.Value = drpOffice.Selected.Value || drpOffice.Selected.Value = "All",
SourceOfMarketing.Value = drpSource.Selected.Value || drpSource.Selected.Value = "All",
Status.Value = drpStatus.Selected.Value || drpStatus.Selected.Value = "All",
Created >= dtfromdate.SelectedDate && Created <= DateAdd(
dttodate.SelectedDate,
1,
Days
)
),
SearchBox.Text,
"FullName",
"Email",
"Phone"
),
Filter(
Candidate_Leads,
OfficeLoacation.Value = drpOffice.Selected.Value || drpOffice.Selected.Value = "All",
SourceOfMarketing.Value = drpSource.Selected.Value || drpSource.Selected.Value = "All",
Status.Value = drpStatus.Selected.Value || drpStatus.Selected.Value = "All",
Created >= dtfromdate.SelectedDate && Created <= DateAdd(
dttodate.SelectedDate,
1,
Days
)
)
),
varSort,
If(
SortDescending1,
Descending,
Ascending
)
)

=================================

This is what i did to all sorting arrows:

========================

UpdateContext({varSort :"FirstName"});
UpdateContext({SortDescending1:false});

================================

I was searching the forum for solutions and someone gave below code:

 

SortByColumns(
  AddColumns(
    SharePoint_List,
    "PersonsName",
    PersonColumn.DisplayName
  ),
  "PersonsName"
)

My problem is, How to add this people column sorting code into my existing item code. Please help. 

---------------------------------------------------------------------------------------------------------------------------


Was I helpful? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. It will help other users to find it faster.

follow me on Twitter @zmansuri123,
connect with me on LinkedIn from Here

1 ACCEPTED SOLUTION

Accepted Solutions
zmansuri
Super User
Super User

Finally This Code worked. I sorted by two columns

1. AssignTo - Which is people type column in sharepoint.

2. Status - Which is choice type column in sharepoint.

=========================================

SortByColumns(
If(
!IsBlank(SearchBox.Text),
Search(
AddColumns(
Filter(
Candidate_Leads,
Year.Value = drpYear.Selected.Value,
Month.Value = drpMonth.Selected.Value,
OfficeLoacation.Value = drpOffice.Selected.Value || drpOffice.Selected.Value = "All",
SourceOfMarketing.Value = drpSource.Selected.Value || drpSource.Selected.Value = "All",
Status.Value = drpStatus.Selected.Value || drpStatus.Selected.Value = "All",
Created >= dtfromdate.SelectedDate && Created <= DateAdd(
dttodate.SelectedDate,
1,
Days
)
),
"AssignToTxt",
AssignTo.DisplayName,"StatusTxt",Status.Value
),
SearchBox.Text,
"FullName",
"Email",
"Phone"
),
AddColumns(
Filter(
Candidate_Leads,
Year.Value = drpYear.Selected.Value,
Month.Value = drpMonth.Selected.Value,
OfficeLoacation.Value = drpOffice.Selected.Value || drpOffice.Selected.Value = "All",
SourceOfMarketing.Value = drpSource.Selected.Value || drpSource.Selected.Value = "All",
Status.Value = drpStatus.Selected.Value || drpStatus.Selected.Value = "All",
Created >= dtfromdate.SelectedDate && Created <= DateAdd(
dttodate.SelectedDate,
1,
Days
)
),
"AssignToTxt",
AssignTo.DisplayName,"StatusTxt",Status.Value
)
),
varSort,
If(
SortDescending1,
Descending,
Ascending
)
)

---------------------------------------------------------------------------------------------------------------------------


Was I helpful? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. It will help other users to find it faster.

follow me on Twitter @zmansuri123,
connect with me on LinkedIn from Here

View solution in original post

5 REPLIES 5
v-jefferni
Community Support
Community Support

Hi @zmansuri ,

 

Please try below:

1\ Modify the variables on the sorting arrows:

UpdateContext({varSort :"PersonName"});
UpdateContext({SortDescending1:false});

 

2\ apply below formula on the Items of the Gallery:

SortByColumns(
If(
!IsBlank(SearchBox.Text),
Search(
Filter(
AddColumns(
    Candidate_Leads,
    "PersonsName",
    PersonColumn.DisplayName
  ),
OfficeLoacation.Value = drpOffice.Selected.Value || drpOffice.Selected.Value = "All",
SourceOfMarketing.Value = drpSource.Selected.Value || drpSource.Selected.Value = "All",
Status.Value = drpStatus.Selected.Value || drpStatus.Selected.Value = "All",
Created >= dtfromdate.SelectedDate && Created <= DateAdd(
dttodate.SelectedDate,
1,
Days
)
),
SearchBox.Text,
"PersonName",
"Email",
"Phone"
),
Filter(
AddColumns(
    Candidate_Leads,
    "PersonsName",
    PersonColumn.DisplayName
  ),
OfficeLoacation.Value = drpOffice.Selected.Value || drpOffice.Selected.Value = "All",
SourceOfMarketing.Value = drpSource.Selected.Value || drpSource.Selected.Value = "All",
Status.Value = drpStatus.Selected.Value || drpStatus.Selected.Value = "All",
Created >= dtfromdate.SelectedDate && Created <= DateAdd(
dttodate.SelectedDate,
1,
Days
)
)
),
varSort,
If(
SortDescending1,
Descending,
Ascending
)
)

 

Hope this helps.

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

 

 

Community Support Team _ Jeffer Ni

If this post helps, then please consider Accept it as the solution to help the other members find it.

SortByColumns(
If(
!IsBlank(SearchBox.Text),
Search(
Filter(
AddColumns(
Candidate_Leads,
"PersonsName",
AssignTo.DisplayName
),
OfficeLoacation.Value = drpOffice.Selected.Value || drpOffice.Selected.Value = "All",
SourceOfMarketing.Value = drpSource.Selected.Value || drpSource.Selected.Value = "All",
Status.Value = drpStatus.Selected.Value || drpStatus.Selected.Value = "All",
Created >= dtfromdate.SelectedDate && Created <= DateAdd(
dttodate.SelectedDate,
1,
Days
)
),
SearchBox.Text,
"PersonName",
"Email",
"Phone"
),
Filter(
AddColumns(
Candidate_Leads,
"PersonsName",
AssignTo.DisplayName
),
OfficeLoacation.Value = drpOffice.Selected.Value || drpOffice.Selected.Value = "All",
SourceOfMarketing.Value = drpSource.Selected.Value || drpSource.Selected.Value = "All",
Status.Value = drpStatus.Selected.Value || drpStatus.Selected.Value = "All",
Created >= dtfromdate.SelectedDate && Created <= DateAdd(
dttodate.SelectedDate,
1,
Days
)
)
),
varSort,
If(
SortDescending1,
Descending,
Ascending
)
)

I just changed the person column name in your given code. Which in my case is "AssignTo". It shows error. 

"The function search has some invalid arguments".

what should i do?

---------------------------------------------------------------------------------------------------------------------------


Was I helpful? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. It will help other users to find it faster.

follow me on Twitter @zmansuri123,
connect with me on LinkedIn from Here

Hi @zmansuri ,

 

Sorry for my unthought-out codes. The question is what's the main purpose that add the display name into the sort function? Would you like to search the full name of Assign To column?

 

If so, below is the correct formula:

SortByColumns(
If(
!IsBlank(SearchBox.Text),
Search(
AddColumns(
Filter(
Candidate_Leads,
OfficeLoacation.Value = drpOffice.Selected.Value || drpOffice.Selected.Value = "All",
SourceOfMarketing.Value = drpSource.Selected.Value || drpSource.Selected.Value = "All",
Status.Value = drpStatus.Selected.Value || drpStatus.Selected.Value = "All",
Created >= dtfromdate.SelectedDate && Created <= DateAdd(
dttodate.SelectedDate,
1,
Days
)
),
"PersonsName",
ThisRecord.AssignTo.DisplayName
),
SearchBox.Text,
"PersonName",
"Email",
"Phone"
),
AddColumns(
Filter(
Candidate_Leads,
OfficeLoacation.Value = drpOffice.Selected.Value || drpOffice.Selected.Value = "All",
SourceOfMarketing.Value = drpSource.Selected.Value || drpSource.Selected.Value = "All",
Status.Value = drpStatus.Selected.Value || drpStatus.Selected.Value = "All",
Created >= dtfromdate.SelectedDate && Created <= DateAdd(
dttodate.SelectedDate,
1,
Days
)
),
"PersonsName",
ThisRecord.AssignTo.DisplayName
),
varSort,
If(
SortDescending1,
Descending,
Ascending
)
)

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

Community Support Team _ Jeffer Ni

If this post helps, then please consider Accept it as the solution to help the other members find it.

Above code gives the following error.

All i want is sort "AssignTo" column in my powerapps gallery. Which is people type column in sharepoint.

11.png

---------------------------------------------------------------------------------------------------------------------------


Was I helpful? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. It will help other users to find it faster.

follow me on Twitter @zmansuri123,
connect with me on LinkedIn from Here

zmansuri
Super User
Super User

Finally This Code worked. I sorted by two columns

1. AssignTo - Which is people type column in sharepoint.

2. Status - Which is choice type column in sharepoint.

=========================================

SortByColumns(
If(
!IsBlank(SearchBox.Text),
Search(
AddColumns(
Filter(
Candidate_Leads,
Year.Value = drpYear.Selected.Value,
Month.Value = drpMonth.Selected.Value,
OfficeLoacation.Value = drpOffice.Selected.Value || drpOffice.Selected.Value = "All",
SourceOfMarketing.Value = drpSource.Selected.Value || drpSource.Selected.Value = "All",
Status.Value = drpStatus.Selected.Value || drpStatus.Selected.Value = "All",
Created >= dtfromdate.SelectedDate && Created <= DateAdd(
dttodate.SelectedDate,
1,
Days
)
),
"AssignToTxt",
AssignTo.DisplayName,"StatusTxt",Status.Value
),
SearchBox.Text,
"FullName",
"Email",
"Phone"
),
AddColumns(
Filter(
Candidate_Leads,
Year.Value = drpYear.Selected.Value,
Month.Value = drpMonth.Selected.Value,
OfficeLoacation.Value = drpOffice.Selected.Value || drpOffice.Selected.Value = "All",
SourceOfMarketing.Value = drpSource.Selected.Value || drpSource.Selected.Value = "All",
Status.Value = drpStatus.Selected.Value || drpStatus.Selected.Value = "All",
Created >= dtfromdate.SelectedDate && Created <= DateAdd(
dttodate.SelectedDate,
1,
Days
)
),
"AssignToTxt",
AssignTo.DisplayName,"StatusTxt",Status.Value
)
),
varSort,
If(
SortDescending1,
Descending,
Ascending
)
)

---------------------------------------------------------------------------------------------------------------------------


Was I helpful? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. It will help other users to find it faster.

follow me on Twitter @zmansuri123,
connect with me on LinkedIn from Here

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (5,034)