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

Sort based on numberic calcualted column is not working for negative numbers

I have sharepoint custom list with 3 columns:-

 

1) ScoreGreenPoint --> of type number

2) ScoreRedPoint --> of type number

3) ScoreFinalScore --> of type calcualted

 

sort.png

 

 

and inside the PowerApp i am sorting based on the above calculated column, as follow:-

 

sorted.png

but the sorting is not working for negative numbers!!  because -1 (1 green point - 2 red points) is larger than -5 (5 green point with 10 red point)!!  any advice?

 

1 ACCEPTED SOLUTION

Accepted Solutions

@johnjohn123 ,

On second thoughts now I see how simple the formula is, you could use AddColumns() and do this

SortByColumns(
   AddColumns(
      Scores,
      "SortField"
      ScoreGreenPoint-ScoreRedPoint
   ),
   SortField,
   Descending
)

 

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
Super User

Hi @johnjohn123 ,

Try to keep away from using SharePoint calculated columns in Power Apps (they will not perform as expected) and do the calculation in Power Apps instead. I would recommend default a number field in SharePoint to the calculation and Patch it with the calculation when anything is changed affecting it.

 

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.

@WarrenBelzto be honest it is weried that such a straightforward sorting will not work.. so how i can do the calculation inside power app and then sort based on the result?

 

I tried these formuals:-

 

SortByColumns(Scores,"ScoreGreenPoint"-"ScoreRedPoint",Descending)

SortByColumns(AddColumns("Scores","ScoreFinalScore",Value(Effect)),"ScoreFinalScore",Descending)

 

 

I also created a Label with this formual:-

tjhis.png

 

 

then i used this formula:-

 

SortByColumns(Scores,Label2,Descending)

 

but did not work !

 

Hi @johnjohn123 ,

I was referring to making the same calculation as the SharePoint calculated column in Power Apps then populating a number field with it (on all records). You would then sort on this column.

What I was pointing out was that there are column type in SharePoint that are really only useful in SharePoint and if referenced in Power Apps cause unwanted hardship. I have done a blog on this if it is useful to you.

 

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.

@WarrenBelz  can you advice more on how i can implement this:-

 

"making the same calculation as the SharePoint calculated column in Power Apps then populating a number field with it (on all records). You would then sort on this column."

@johnjohn123 ,

On second thoughts now I see how simple the formula is, you could use AddColumns() and do this

SortByColumns(
   AddColumns(
      Scores,
      "SortField"
      ScoreGreenPoint-ScoreRedPoint
   ),
   SortField,
   Descending
)

 

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.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

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