Skip to main content

Notifications

Community site session details

Community site session details

Session Id : 23wFUuUEn+5sr5W9v9TT9Y
Power Apps - Building Power Apps
Answered

sort by date range

Like (0) ShareShare
ReportReport
Posted on 9 Apr 2021 05:34:30 by 395

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:
  • Matt383 Profile Picture
    395 on 09 Apr 2021 at 21:57:13
    Re: sort by date range

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

  • Verified answer
    WarrenBelz Profile Picture
    146,508 Most Valuable Professional on 09 Apr 2021 at 21:46:07
    Re: sort by date range

    @Matt383 ,

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

  • Matt383 Profile Picture
    395 on 09 Apr 2021 at 21:42:49
    Re: sort by date range

    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

     

     

  • WarrenBelz Profile Picture
    146,508 Most Valuable Professional on 09 Apr 2021 at 07:35:24
    Re: sort by date range

    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
    395 on 09 Apr 2021 at 06:19:00
    Re: sort by date range

    Matt383_0-1617948955819.png

    Matt383_1-1617949108965.png

     

    before and after

  • Matt383 Profile Picture
    395 on 09 Apr 2021 at 06:15:00
    Re: sort by date range

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

  • WarrenBelz Profile Picture
    146,508 Most Valuable Professional on 09 Apr 2021 at 06:05:27
    Re: sort by date range

    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.

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

Thomas Rice – Community Spotlight

We are honored to recognize Thomas Rice as our March 2025 Community…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,508 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,369 Most Valuable Professional

Leaderboard
Loading started