cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
audrieg
Power Automate
Power Automate

Sort Ascending / Decending

What property drives which colum will be sorted when tapping the sort ascending/decending icon? Mine seems to be doing it's own thing. Smiley Frustrated

 

sort.PNG

28 REPLIES 28

Hi, there is no small limit to nesting of If statements that I am aware of, so three should be fine.

Why is there a Search function in your Items property without any search parameters?


@HuseyinAhmet wrote:

As one small follow up, I've tried sorting by a third value, DEF, however whenever I try to add this as a third If condition, nothing seems to work, are conditions locked to 2 max or is there some sort of workaround? 



Hi

 

Sorry for intervening into the discussion. May I suggest another way?

 

You can still maintain the TextSearchBox, and replace the Sorted Column with DropDown.

- Create a Dropdown with: Items = ["Name",  "ATK", "DEF']

- Replace the Sorted column, example, Name, with Dropdown.Selected.Value

 

SortByColumns(Search(MyDataSource, TextSearchBox1.Text, "Name", "ATK", "DEF"), Name, If(SortDescending1, Descending, Ascending))....Replaced with

SortByColumns(Search(MyDataSource, TextSearchBox1.Text, "Name", "ATK", "DEF"), Dropdown.Selected.Value, If(SortDescending1, Descending, Ascending))

 

So, when you Select the items in the Dropdown, and press on Sort (Up-Down Arrow) button, it will sort based on the dropdown selected button.

 

Please see my sample and hope it meets what you want in a simple way.

 

Screenshot (50).pngScreenshot (51).png

hpkeong

To answer the Search parameter question, that is there because in my actuall app I am seraching for things, I did not want to post all of the parameters here.
I also managed to solve the issue with certain numbers not sorting correctly, this was because they were being sorted as plain text rather than as variables.
Finally I Also Fixed the third If statement Issue, I was doing something slightly wrong with the close brackers, everything is working how I would like it to, but thanks again for the response SteelMan.

hpkeong
Community Champion
Community Champion


@audrieg wrote:

That worked!  (I am going to put an idea in that they made the change behind the scenes as the gallery items are selected.)

 

Thank you!



Hi

 

I have added in this thread that you can use Dropdown.Selected.Value to replace the Sorted Column and bind to a Dropdown to make the sorting a dynamic one based on what you select.

Please see my reply in one of the thread here.

 

TQ

hpkeong

Hello hpkeong,

 

I will give this a go, and maybe use both to compare which is better.

Thanks,

Huseyin.

Hi

 

All methods are OK to you.

I just wish to share another option that just add a dropdown without adding many Sorting Buttons.

Smiley Happy

hpkeong

Hey hpkeong,

A quick question about how things are sorted with the drop down, I am running into an issue that I had previously when sorting DEF with the previous version. DEF are numerical values, and I believe because powerapps was taking the numbers as plain text values, when they were sorted they would appear as such:

0
1000
1500
150
1600
3000
400

When what I would want would be:

0
150
400
1000
1500
1600
3000

To fix this issue I made sure that when sorting by ATK I sorted by its value, for example:


Sort(Search(MyDataSource, TextSearchBox1.Text, "NAME", "ATK", "DEF"), Value(DEF), If(SortDescending3, Descending, Ascending))

Now when sorting with the dropdown, it takes the value of the selected item on the list, but returns the plaintext sorted list rather than the value sorted list, which is not what I want:

SortByColumns(Search(MyDataSource, TextSearchBox1.Text, "NAME", "ATK" ,"DEF"), Dropdown1.Selected.Value, If(SortDescending1, Ascending, Descending))

I've tried Value(Dropdown1.Selected.Value) and I've tried making the Items in the dropdown Value("ATK") but neither of these seem to work, would you know why this is happening?

hpkeong
Community Champion
Community Champion

Hi

 

I tried, too, on Sample Data from Tutorial.

Even the sample data shown also can;t sort as expected for NUMBER.

In this case, I am sorry for not able to provide solution ehere and hpe someone or PG can come it to help clarify the proper solution to sort Number, in dequence (instead of of based on the 1, 2, 3, 4,...).

 

Sample screenshot of failure.

Screenshot (52).png

hpkeong
Meneghino
Community Champion
Community Champion

Hi @hpkeong and @HuseyinAhmet

I could not reproduce your issue, I can get numbers stored as text to be sorted numerically by using the AddColumns function like in the following screenshot.

Or do I misunderstand your issue?  In that case, please provide steps to reproduce.

 

CaptureSorting.JPG

hpkeong
Community Champion
Community Champion

Hi

 

In fact, Sorting is possible except when you have 1, 2, 3, 4,...10, 11,12,...and above.

1 ~ 10 will affects the sorting.

Example:

1, 10, 11, 2, 12, 3, 4, 5, 6, 7, 8,...

So, if you do not hvae 1 ~ 10, but start from 10, it has no problem,

 

 

hpkeong

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (75,689)