web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Need help to sort a da...
Power Apps
Answered

Need help to sort a date/time column from SP to ascend

(0) ShareShare
ReportReport
Posted on by Microsoft Employee
Filter( Sort( 'Logg'; 'Last contact';Ascending); Agreementarea.Value in "Location1" & "Location2"; Status.Value in "Ongoing" & "Finished" ); Filter( Sort( 'Logg'; 'Last contact';Ascending); Agreementarea.Value in 'Filter agreementarea'.SelectedItems.Value ; Status.Value in "Ongoing" & "Finished" ))

 

 

What i'm trying to accomplish is that you can filter with a dropdown meny called "Filter agreementarea" or toggle a button and instant get all choices in the agreementarea shown in the gallery

Hello!

 

I got this problem where I try to sort on a date/time column (Last contact) from an SP list in Powerapps and for some reason it doesnt work.

 

This code gives no errors but the gallery is just blank:

If('Toggle'.Value; 
Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    155,723 Most Valuable Professional on at

    @Anonymous ,

    You have just posted the same code that we have spend 26 posts correcting on this thread.

    Obviously, you do not wish further assistance from me, but whoever picks this one up needs to know the history or they will be starting from the beginning. Your problem is not your sort - it is your filters, which I believe have already been corrected in the other thread and yet you post the originals code again.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Is there anyone who can help me? 🙂

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hey guys! I really need some help with this. I really appreciate the help!

  • v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    Can the code work properly without any sort() function?  What is the Items property of 'Filter agreementarea' combobox?

    The code looks good, if the code without the sort() function can work perfectly, how about trying some other sort functions?

    Try this out:

    SortByColumns( 
    If('Toggle'.Value;
    Filter(
     'Logg';
    Agreementarea.Value in "Location1" & "Location2";
    Status.Value in "Ongoing" & "Finished"
     );
    Filter(
     'Logg';
     Agreementarea.Value in 'Filter agreementarea'.SelectedItems.Value ;
     Status.Value in "Ongoing" & "Finished"
     )
    );"Last contact";Ascending)

    Hope this helps.

    Sik 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @v-siky-msft Hello!

     

    My code doesnt seem to work when I try without the Sort() function.. 


    This is the item property of the "Filter agreementarea" combox:

    Choices(Logg.Agreementarea)

     

    I tried the code you provided and the gallery is just blank 😞 

  • v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    So, it seems the problem isn't due to the sort function, because the filter formula doesn't even work.

    Please share more information about your scenario.

    What are the data types of these columns in Logg list? 

    How many rows are there in in Logg list? 

    Could you please share more snapshots to display what you want to achieve?

     

    Sik

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @v-siky-msft There is over 11k rows in this sharepoint list, but that what the filter is for.

     

    Columns in logg list:

    Last contact = an date/time field in SP list where users with a lookup can choose date and time, as seen in the screenshot of my first post.

    ThisItem.'Last contact"

    Agreementarea = An choice field in SP list where you can only choose 1 alternative out of 5.

    Items property:

    Choices('Logg'.Agreementarea)

     

    Status = An choice field in SP list where you can only choose 1 alternative out of 6.

    Item property:

    Choices('Logg'.Status)

     

    As I explained before, you can choose to either sort by "Sortera på avtalsområde" (Filter agreementarea) or use the toggle to show some other filters, toggle should overwrite the other filter.

     

     last contact ascending pic2.png

  • WarrenBelz Profile Picture
    155,723 Most Valuable Professional on at

    @Anonymous ,

    I will leave you with @v-siky-msft , but you are being told the same thing I spent 13 posts telling you on this thread.

     

  • Verified answer
    v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    OK, obviously the formula isn't delegable because of the in operator, not to mention, you have 11K rows data, so I suspect that it's a delegation issue. What you filter exceed the maximum threshold (2000), the gallery only shows blank.

     

    If my assumption is correct, here is a workaround for this issue.

    1. set OnChange property of "Filter agreementarea" combox as follows, save each selected option into variable.

    Concurrent(
     Set(
     v1,
     Last(
     FirstN(
     Self.SelectedItems,
     1
     )
     ).Value
     ),
     Set(
     v2,
     Last(
     FirstN(
     Self.SelectedItems,
     2
     )
     ).Value
     ),
     Set(
     v3,
     Last(
     FirstN(
     Self.SelectedItems,
     3
     )
     ).Value
     ),
     Set(
     v4,
     Last(
     FirstN(
     Self.SelectedItems,
     4
     )
     ).Value
     ),
     Set(
     v5,
     Last(
     FirstN(
     Self.SelectedItems,
     5
     )
     ).Value
     )
    )

    2. modify the Gallery.Items property as follow, remove In operator, change to user = operator to match each criterion.

    If('Toggle'.Value;
    Filter( 
     Sort('Logg';'Last contact';Ascending);
    Agreementarea.Value = "Location1" ||
    Agreementarea.Value = "Location2";
    Status.Value = "Ongoing" ||
    Status.Value = "Finished"
     );
    Filter(
     Sort('Logg';'Last contact';Ascending);
     Agreementarea.Value = v1 || Agreementarea.Value = v2 || Agreementarea.Value = v3 || Agreementarea.Value = v4 || Agreementarea.Value = v5 ||;
     Status.Value = "Ongoing" ||
     Status.Value = "Finished"
     ))

    Hope this helps.

    Sik

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @v-siky-msft Thank you, this worked! I really appreciate your help with this 😃

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 475

#2
WarrenBelz Profile Picture

WarrenBelz 387 Most Valuable Professional

#3
11manish Profile Picture

11manish 289

Last 30 days Overall leaderboard