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 by date range

(0) ShareShare
ReportReport
Posted on by 407

Hi, Just added a sort icon into the gallery to filter by recent date. The Onselect of the icon has UpdateContext({SortDescending1:true})

and in the items of the gallery i currently have,

Filter(KBLCollection,StartsWith(Title,Srchbox.Text) && (Dropdown1.Selected.Value = "all" || If( Dropdown1.Selected.Value="Submitted",Submitted,!Submitted)))

 

I thought i could put in something like this, 

Filter(KBLCollection,StartsWith(Title,Srchbox.Text) && (Dropdown1.Selected.Value = "all" || If( Dropdown1.Selected.Value="Submitted",Submitted,!Submitted))),"Date" , If(SortDescending1, Descending, Ascending))

but no luck, can you please assist

 

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    154,447 Most Valuable Professional on at

    Hi @Matt383 ,

    You had an extra closing bracket in there

    Filter(
     KBLCollection,
     StartsWith(
     Title,
     Srchbox.Text
     ) && 
     (
     Dropdown1.Selected.Value = "all" || 
     If( 
     Dropdown1.Selected.Value="Submitted",
     Submitted,
     !Submitted
     )
     ),
     "Date", 
     If(
     SortDescending1, 
    	 Descending, 
    	 Ascending
     )
    )

    You could also toggle the sort with 

    UpdateContext({SortDescending1:!SortDescending1})

    I am assuming here Submitted is a Boolean (yes/no) field.

     

    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.

  • Matt383 Profile Picture
    407 on at

    Hi Warren, thanks for your reply. It no longer brings any errors, however now nothing shows in the gallery

  • Matt383 Profile Picture
    407 on at

    Matt383_0-1617948955819.png

    Matt383_1-1617949108965.png

     

    before and after

  • WarrenBelz Profile Picture
    154,447 Most Valuable Professional on at

    Hi @Matt383 ,

    Dangers of free-typing - you left out Sort

    Sort(
     Filter(
     KBLCollection,
     StartsWith(
     Title,
     Srchbox.Text
     ) && 
     (
     Dropdown1.Selected.Value = "all" || 
     If( 
     Dropdown1.Selected.Value="Submitted",
     Submitted,
     !Submitted
     )
     )
     ),
     Date, 
     If(
     SortDescending1, 
     Descending, 
     Ascending
     )
    )

     

    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.

  • Matt383 Profile Picture
    407 on at

    Thanks Warren, Gallery showing up now, no errors. however when i  select the sort icon, nothing changes. The date fields in the gallery remain randomly throughout. I checked the onselect of the icon
    UpdateContext({SortDescending1:true})

    and the onselect of the gallery is

    Sort( Filter( KBLCollection, StartsWith( Title, Srchbox.Text ) && ( Dropdown1.Selected.Value = "all" || If( Dropdown1.Selected.Value="Submitted", Submitted, !Submitted ))), "Date", If(SortDescending1, Descending, Ascending ))

    Also when i select the sort icon, the blue box stays there (image below)

    Matt383_0-1618004506677.png

     

     

  • Verified answer
    WarrenBelz Profile Picture
    154,447 Most Valuable Professional on at

    @Matt383 ,

    Also forgot to take the quotes off "Date" - now fixed.

  • Matt383 Profile Picture
    407 on at

    Thanks Warren, thats the one. All sorted now. Cheers

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 542 Most Valuable Professional

#2
Haque Profile Picture

Haque 206

#3
Kalathiya Profile Picture

Kalathiya 201 Super User 2026 Season 1

Last 30 days Overall leaderboard