web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / how to sort the date r...
Power Apps
Unanswered

how to sort the date range and the gallery date by descending???? need help to solve. -- anyone can help.. thanks

(0) ShareShare
ReportReport
Posted on by 1,994

hi

 

 

 

bbsin_0-1626062823279.png

 

Hi

I want to use the drop down to show.. on visible I set the syntax.    Let me input yr syntax and see .. thanks

 

Can I ask u how to sort the gallery -- I use the start date and end date as date field and Start time and end time as text field which I saw in April video Date Rang but she didn't show the full so I am confused she uses dropdown for the date - drop.selected.date in powerapps sort but she mention it's a date field and time is text field.

 

Gallery - sort(filter(list, date >= dropdown.selected.startdate && date <=dropdown.selected.enddate), Date, Descending

 

I want to sort the gallery to descending as start date and time

 

 

 

cannot  link it together as I don't know how to sort in the gallery.. can someone pls help thx

 

Categories:
I have the same question (0)
  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    I don't think we can sort the text field as the date. We need to create a collection with the transformation which converts Start Date & Time to one field with DateTime format. Then we can do regular sorting

     

    SortByColumns(Filter([Issuetracker], StartsWith(Title, TextSearchBox1.Text)), "DateReported", If(SortDescending1, Descending, Ascending))
  • bbsin Profile Picture
    1,994 on at

    Hi @StalinPonnusamy 

     

    I dont have a search box .. the top is a drop down.. 

    is the Date Reported  = Start Date?  how abt the time?

    is it like that?  Thanks

     

    Start date and time are using input text box

    SP for time is text single .. must I change?

     

    SortByColumns(Filter(list], StartsWith(StartDate, dpbox.Text)), "StartDate", If(SortDescending1, Descending, Ascending))

    bbsin_1-1626075995682.png

     

     

     

    1.PNG

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @bbsin

     

    My recommendation is to change the column in SP to Data and time type as a single field which is appropriate. So that you don't need to worry about the conversation in all other places.

     

    On dropdown change event find startdate and enddate based on the selection and always use those dates in the filter

    Dropdown/Combobox onchange event

    If(
     ComboBox1.Selected.Value = "ThisMonth",
     Set(
     Startdate,
     DateValue(Month(Now()) & "/1/" & Year(Now()))
     );
     Set(
     Enddate,
     Today()
     )
    );
    If(
     ComboBox1.Selected.Value = "LastMonth",
     Set(
     Startdate,
     DateValue(Month(Now())-1 & "/1/" & Year(Now()))
     );
     Set(
     Enddate,
     DateAdd(DateValue(Month(Now())-1 & "/31" &"/" & Year(Now())),-1,Days)
     )
    );

    Gallary Filter

     

    SortByColumns(
     Filter(
     [@Accounts],
     'Created On' > Startdate && 'Created On' < Enddate
     ),
     "accountnumber",
     If(
     SortDescending1,
     Descending,
     Ascending
     )
    )

     

     

    If you like this post, give it a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users to find it.

  • bbsin Profile Picture
    1,994 on at

    Hi @StalinPonnusamy 

     

    To clarify, - My recommendation is to change the column in SP to Data and time type as a single field which is appropriate. 

     

    do you mean to change the time column or date column to singleline of text?  Thanks

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Change both fields as single field and data type as "Date & Time" like below

     

    StalinPonnusamy_0-1626154819551.png

    If combining is not possible then we need to do the transformation from data source to collection and apply filter

  • bbsin Profile Picture
    1,994 on at

    Hi  @StalinPonnusamy 

     

    I cannot get it..

    bbsin_1-1630309570663.png

     

     

     

    SortByColumns(
     Filter(
     [@Accounts],
     'Created On' > Startdate && 'Created On' < Enddate
     ),
     "accountnumber",
     If(
     SortDescending1,
     Descending,
     Ascending
     )
    )

    am back to try out to build this.. but what is account number ??

     

    is @Account the  SP name and I want to sort by title and date descending.  - nothing show up?

     

    Filter(
    AdminEventInfo,
    StartDate > Startdate && EndDate < Enddate
    ),
    Title,
    If(
    SortDescending1,
    Descending,
    Ascending
    )
    )

     

    bbsin_0-1630309441887.png

     

     

    Thanks

     

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @bbsin 

     

    Edited: Added to get Start and end date for each dropdown option.

     

    1. Place dropdown and set the Items property to 

     

    ["This Week","This Month","Previous Month","Next Month"]

     

    2. Set Onchange property of Dropdown to (Change to your dropdownname instead of Dropdown6)

     

    If(
     Dropdown6.Selected.Value = "This Month",
     Set(
     CalculatedStartdate,
     DateValue(Month(Now()) & "/1/" & Year(Now()))
     );
     Set(
     CalculatedEnddate,
     Today()
     )
    );
    If(
     Dropdown6.Selected.Value = "Previous Month",
     Set(
     CalculatedStartdate,
     DateValue(Month(Now()) - 1 & "/1/" & Year(Now()))
     );
     Set(
     CalculatedEnddate,
     DateAdd(
     DateValue(Month(Now()) - 1 & "/31" & "/" & Year(Now())),
     -1,
     Days
     )
     )
    );
    If(
     Dropdown6.Selected.Value = "Next Month",
     Set(
     CalculatedStartdate,
     DateValue(Month(Now()) + 1 & "/1/" & Year(Now()))
     );
     Set(
     CalculatedEnddate,
     DateAdd(
     DateValue(Month(Now()) + 1 & "/31" & "/" & Year(Now())),
     -1,
     Days
     )
     )
    );
    If(
     Dropdown6.Selected.Value = "This Week",
     Set(
     CalculatedStartdate,
     DateAdd(
     Now(),
     -(Weekday(
     Now(),
     StartOfWeek.MondayZero
     )),
     Days
     )
     );
     Set(
     CalculatedEnddate,
     DateAdd(
     Now(),
     6-(Weekday(
     Now(),
     StartOfWeek.MondayZero
     )),
     Days
     )
     )
    );

     

     3. Gallery Items property to

     

    SortByColumns(
     Filter(
     AdminEventInfo,
     StartDate > CalculatedStartdate && EndDate < CalculatedEnddate
     ),
     "Title",
     If(
     SortDescending1,
     Descending,
     Ascending
     )
    )

     

  • bbsin Profile Picture
    1,994 on at

    Hi @StalinPonnusamy 

     

    Great appreciated your help.

     

    the gallery have error on my end.  Can I know what is the SortDescending1?

    bbsin_0-1630399263158.png

     not sure where I need to edit.  Thank you

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @bbsin 

     

    SortDescending1 is a variable for sorting

     

    Option 1: (Always Descending by Startdate)

     

    SortByColumns(
     Filter(
     AdminEventInfo,
     StartDate > CalculatedStartdate && EndDate < CalculatedEnddate
     ),
     "StartDate",
     Descending
    )

     

     

    Option 2: if you need sorting to toggle like Ascending and descending alternatively then

     

    • Add icon and set Onselect property to
    • UpdateContext({SortDescending1: !SortDescending1})
    • Set Gallery Items Property to
    • SortByColumns( Filter( AdminEventInfo, StartDate > CalculatedStartdate && EndDate < CalculatedEnddate ), "StartDate", If( SortDescending1, Descending, Ascending ) ) 

     

  • bbsin Profile Picture
    1,994 on at

    HI, @StalinPonnusamy 

     

    the syntax works , but there a few questions and two didn't display

     

    1) notice that only user select the drop down then the gallery item will display; 

    how to display by descending items when there no selected in the drop down?

    bbsin_0-1630462841563.png

     

    2) I selected this Month and pervious month but nothing appear ; however it appears for this week and next month

    bbsin_1-1630462935289.png

    bbsin_2-1630463390323.png

     

    3) how to set default to show all event happening when the app opens .  Thanks

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard