cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
phh
Helper IV
Helper IV

Sort Column value from biggest to lowest

Hi all,

I have tried to search for something that could give a lot of the answer to how many filter function that can rank the values ​​from largest to smallest and vice versa.

That's the value of "ha missing" I would like to have ranked

If it can be explained step by step it will be very nice!!!

I hope you can help me, please!

See the picture
-Peter

2 ACCEPTED SOLUTIONS

Accepted Solutions

@phh 

Power Apps, calculated columns can sometimes behave like strings, even when you define the column as numeric.

I would try Warren's suggestion. If it still doesn't sort correctly, you could try modifying it so that it calls the Value function to convert your 'Ha_x0020_mangler' calculated column to a number like so:

SortByColumns(
   AddColumns(   
      Jordprøver5,
      "HAMissing"
      Value(Ha_x0020_mangler)
   ),
   HAMissing,
   If(
      varSortAscending,
      Ascending,
      Descending
   )
)

 

View solution in original post

Hi Peter,

I'm glad that works. You can use AddColumns to add 'Ha Mangler' like so.

 

SortByColumns(AddColumns(Jordpr0ver5, "valHaBestilt", Value(HaBestilt), "valHaMangler", Value(HaMangler)),
              SortPriority,
              If(SortDescending,Ascending,Descending)
)

 

You can then sort that column with this formula.

UpdateContext({SortPriority:"valHaMangler",
               SortDescending:!SortDescending}
)

 

View solution in original post

28 REPLIES 28
timl
Super User
Super User

Hi  Peter,

The SortByColumns can help you.

https://docs.microsoft.com/en-gb/powerapps/maker/canvas-apps/functions/function-sort 

In this case, you would amend the Items property of your gallery using the formula beneath.

SortByColumns( <InsertExistingItemsFormulaForGallery1>, 
             "ha missing", Descending  
)

 

TJO
Resolver II
Resolver II

@phh You can set you gallery items property to sort depending on a boolean variable:

 

 

SortByColumns(
   tabDaten,
   "Ha Missing",
   If(
      varSortAscending,
      Ascending,
      Descending
   )
)

 

 

 Then on the sort button OnSelect property you toggle the boolean variable:

 

 

Set(varSortAscending, !varSortAscending)

 

 

So without setting pressing the sort button the sorting should be descending upon loading at first since varSortAscending will be blank/false.

 

Hi @TJO,

It just turns the column around. the black not on the values.

See the pictures

TJO
Resolver II
Resolver II

@phh That is weird. Maybe there is a problem with the space in your column name (if your data is in SharePoint or Excel). Could you try with "ha_x0020_missing"

Hi @TJO 
No?

TJO
Resolver II
Resolver II

@phh mmh, could you paste your whole formula in here please

Hi @TJO,

The first formula is for the gallery and the second formula is for the icon.

SortByColumns(
             Jordprøver5,
             "Ha_x0020_mangler",

                If( varSortAscending,
                Ascending,
                Descending
         )
)



Set(varSortAscending, !varSortAscending)


-Peter

TJO
Resolver II
Resolver II

@phh The formulas seem correct.
Could this be a number stored as text issue?  

Hi @TJO,

 The field is a calculated field and is, and it is set to number.

-phh

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power Apps Community Call Jan. 2022 768x460.png

Power Apps Community Call

Please join us on Wednesday, January 19th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,638)