cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Shane_Dev
New Member

Can't sort by Choice Value with SortByColumns

So I have tried:

 

SortByColumns(Filter([@MyList], StartsWith(Approve.Value, TextSearchBox1.Text)), "Approve", If(SortDescending1, Descending, Ascending))

 

But I cannot sort on the "Approve" value.

 

The above works if I change "Approve" to "ID" or "Title" though.

 

Note: This is from a SPO list

 

I am still new but this is boggling to me.

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User III
Super User III

Hi @Shane_Dev ,

I am assuming "Approve" is a Lookup field - you cannot sort on this. Try

SortByColumns(
   AddColumns(
      Filter(
         [@MyList], 
         StartsWith(
            Approve.Value, 
            TextSearchBox1.Text
         )
      ),
      "Approval",
      Approve.Value
   ),
   "Approval", 
   If(
      SortDescending1, 
      Descending, 
      Ascending
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

View solution in original post

5 REPLIES 5
WarrenBelz
Super User III
Super User III

Hi @Shane_Dev ,

I am assuming "Approve" is a Lookup field - you cannot sort on this. Try

SortByColumns(
   AddColumns(
      Filter(
         [@MyList], 
         StartsWith(
            Approve.Value, 
            TextSearchBox1.Text
         )
      ),
      "Approval",
      Approve.Value
   ),
   "Approval", 
   If(
      SortDescending1, 
      Descending, 
      Ascending
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

View solution in original post

Approve is a choice field (Yes, No, Empty)

That appears to have worked!

 

Now, one last question is how do i add another column to this list in the similar fashion. So lets say I want to add Status.Value as well as the Approve.Value

 

Is it as simple as just going:

SortByColumns(
    AddColumns(
		Filter(
        [@MyList],
        StartsWith(
            Approve.Value,
            TextSearchBox1.Text
			)
		), 
	    "Unicorns", 
		Approve.Value,
		"Test",
		Status.Value
	),
	"Test",
    If(
        SortDescending1,
        Descending,
        Ascending
    )
)

@Shane_Dev ,

Yes, that should work also.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Thanks! You the man!

 

I am still learning but this is pretty cool.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (2,069)