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. 

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
)
)

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?

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

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
)
)

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

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