Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

sort by date range

(0) ShareShare
ReportReport
Posted on 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
    Matt383 395 on at
    Re: sort by date range

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

  • Verified answer
    WarrenBelz Profile Picture
    WarrenBelz 145,580 on at
    Re: sort by date range

    @Matt383 ,

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

  • Matt383 Profile Picture
    Matt383 395 on at
    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
    WarrenBelz 145,580 on at
    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
    Matt383 395 on at
    Re: sort by date range

    Matt383_0-1617948955819.png

    Matt383_1-1617949108965.png

     

    before and after

  • Matt383 Profile Picture
    Matt383 395 on at
    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
    WarrenBelz 145,580 on at
    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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

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

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,580

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,909

Leaderboard