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 Apps
Answered

Sort dropdown

(0) ShareShare
ReportReport
Posted on by

I have a dropdown with its Items being a collection: BLUFDate. BLUFDate is Distinct(ExpenseMaster, 'Date') so it will gather all the dates from a SP list. Within the dropdown I want to sort the dates in order from newest to oldest. What formula should I use to do this?

Categories:
I have the same question (0)
  • cavitha Profile Picture
    50 on at

    Check this link - https://www.spguides.com/power-apps-sort-gallery/

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @kingy61422 

    Your formula would be:

    Sort(BLUFDate, Result, Descending)

     

    I hope this is helpful for you.

  • kingy61422 Profile Picture
    on at

    To better describe what I'm doing. I'm trying to sort the Dates in the collection, BLUFDate, from newest to oldest with "All" being first and have the collection be the Items property of a dropdown

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @kingy61422 

    Just skip the collection then and set your Items property to:

    UnGroup(
     Table({Items: Table({Result:"All"})},
     {Items: Sort(Distinct(ExpenseMaster, 'Date'), Date, Descending)}
     ),
     "Items"
    )
  • kingy61422 Profile Picture
    on at

    After being more thorough, when I put either code in my Items property it sorts but one date doesn't.

    kingy61422_0-1665073312742.png

     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @kingy61422 

    How are your dates stored in the ExpenseMaster list?  Or in other words, what kind of column is 'Date' in your list?

  • kingy61422 Profile Picture
    on at

    Its a single line of text but I also have a Date and Time

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @kingy61422 

    Sorting dates, times, numbers, etc. that are all in Text will not yield correct results.

    For example,  1, 2, 3, 100, 0100, 200 if all in text would sort to the following:

    "0100", "1", "100", "2", "200", "3"

    Not what you expect!!  Same for dates.

     

    So, you will need to change your formula to the following:

    UnGroup(
     Table({Items: Table({Result:"All"})},
     {Items: ForAll(
     Sort(
     ForAll(Distinct(ExpenseMaster, 'Date'), 
     DateValue(Result)
     ),
     Value, Descending
     ),
     {Result: Text(Value, ShortDate)}
     )
     }
     ),
     "Items"
    )

     

    In the above, we need to convert the date text to a real date for the sort, then convert it back to text so that you can use the All (which is text).  This is important to understand because you would NOT have been able to just convert the text to a date and sorted all in that formula because the datatype would "collide".  In the first Table, Result is Text, then in the second Table it would have been Date...that would not have worked.

    So, in the above formula, that is why I am showing to convert from text to date, sort, then convert from date to text.

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 April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 414

#2
Valantis Profile Picture

Valantis 408

#3
timl Profile Picture

timl 339 Super User 2026 Season 1

Last 30 days Overall leaderboard