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 / Sort dropdown items
Power Apps
Answered

Sort dropdown items

(0) ShareShare
ReportReport
Posted on by 147

Hi,

 

I have a dropdown with items that uses the following code:

 

Sort(
 Distinct(
 Filter(
 'Dataset',
 Year = YearSelector.Selected.Value
 ),
 'Week Number'
 ),
 SortOrder.Ascending
)

 

In short, I only want to see week numbers in the dropdown, that are available for the selected year. This part functions as expected - I am not getting week 52 to show up for year 2024, for example.

 

The issue I have is that the SortOrder doesn't seem to work and I am unsure what's causing that issue. Here you see the order seems rather random:

Danil_1-1707481336150.png

I reckon it might be referring to another value when activating the SortOrder. What can I do to fix this?

Categories:
  • NPPlatform Profile Picture
    606 Moderator on at

    You need to include the column you want to sort on. Something like:

     

    Sort(
     Distinct(
     Filter(
     'Dataset',
     Year = YearSelector.Selected.Value
     ),
     'Week Number'
     ),
     'Week Number',
     SortOrder.Ascending
    )

    You can find more information in the documentation here: https://learn.microsoft.com/en-us/power-platform/power-fx/reference/function-sort. Let me know if this helps!

  • Daniël Profile Picture
    147 on at

    Hi, 

     

    Thank you for the reply. So I thought it might have been something like that as well, but then the entire code fails. It also says 'Week Number' isn't recognized, which I find odd.

     

    Could it have something to do with the fact that it's a Dataverse table, should I use different formatting? Most of my experience is with Sharepoint, so I might miss something small, yet essential. My column info:

    Danil_1-1707484900901.png

     

  • Daniël Profile Picture
    147 on at

    Does anyone have insights on this? 

  • Verified answer
    NPPlatform Profile Picture
    606 Moderator on at

    Hi, I made an error in my previous reply. The column you want to sort on should be Value, not 'Week Number'. Thus the following code should work correctly:

     

     

    Sort(
     Distinct(
     Filter(
     'Dataset',
     Year = YearSelector.Selected.Value
     ),
     'Week Number'
     ),
     Value,
     SortOrder.Ascending
    )

     

     

    When encountering errors in the future, try to build your formula step-by-step and see what suggestions Power Apps has for you. I found the solution by writing the Distinct()-formula, inserting a comma and seeing what the suggestions from Power Apps were. See the below screenshot, where Power Apps suggests 'ThisRecord' and 'Value'. By trying each suggestion you'll often find the solution.

     

    NPPlatform_0-1707992740457.png

     

    If this answer solves your question, consider marking it as the solution for future users!

  • Daniël Profile Picture
    147 on at

    Such a simple solution, but I definitely needed your help for it. Thank you, also for the other advice!

  • NPPlatform Profile Picture
    606 Moderator on at

    No problem! 

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 312

#3
Mohsin Ali Profile Picture

Mohsin Ali 252

Last 30 days Overall leaderboard