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 / Sort does not work cor...
Power Apps
Unanswered

Sort does not work correct when filter contains date

(0) ShareShare
ReportReport
Posted on by 8

my sort changes once i add a date in the filter. if i remove the date from the filter the sort shows the latest by date created when i add the date to the filter is sort change to QC_LOT_NUMBER ascending and Date Created Descending. ive removed everything except the date but same issue.

 

does anyone know how i can resolve this issue?

 

SortByColumns(
Filter(ZZQCLTS

,StartsWith(QC_LOT_NUMBER,LotSearch.Text)
,StartsWith(PART_NUMBER,PartNumSearch.Text)
,StartsWith(COMMERCIAL_PART_NO , CommerialPartSearch.Text)
,If(!IsBlank(DatePicker1.SelectedDate), DateValue( DATE_MANUFACTURED,"EN-us") = DatePicker1.SelectedDate , true)
), "DATE_CREATED", Descending)

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

    Hi @agonciulea ,

    The code below (slightly modified) should certainly sort by DATE_CREATED descending - are you saying it does not?

    SortByColumns(
     Filter(
     ZZQCLTS,
     StartsWith(QC_LOT_NUMBER,LotSearch.Text),
     StartsWith(PART_NUMBER,PartNumSearch.Text),
     StartsWith(COMMERCIAL_PART_NO,CommerialPartSearch.Text),
     (IsBlank(DatePicker1.SelectedDate) || DateValue(DATE_MANUFACTURED,"EN-us") = DatePicker1.SelectedDate)
     )
     ),
     "DATE_CREATED", 
     Descending
    )

     

    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.

    Visit my blog Practical Power Apps

  • agonciulea Profile Picture
    8 on at

    Unfortunately that didnt work

     

    here are the result with out the date filter 

    agonciulea_1-1646349762706.png

     

     

    here are the results with the date filter

    agonciulea_0-1646349750552.png

     

    here is the formula, i did change the !IsBlank to IsBlank but 

     

    Sort(
    Filter(
    ZZQCLTS,
    StartsWith(QC_LOT_NUMBER,LotSearch.Text),
    StartsWith(PART_NUMBER,PartNumSearch.Text),
    StartsWith(COMMERCIAL_PART_NO, CommerialPartSearch.Text),
    (IsBlank(DatePicker1.SelectedDate) || DateValue(DATE_MANUFACTURED, "EN-us") = DatePicker1.SelectedDate)
    ),
    DATE_CREATED,
    Descending
    )

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Hi @agonciulea ,

    Your code

    Sort(
     Filter(
     ZZQCLTS,
     StartsWith(QC_LOT_NUMBER,LotSearch.Text),
     StartsWith(PART_NUMBER,PartNumSearch.Text),
     StartsWith(COMMERCIAL_PART_NO, CommerialPartSearch.Text),
     (IsBlank(DatePicker1.SelectedDate) || DateValue(DATE_MANUFACTURED, "EN-us") = DatePicker1.SelectedDate)
     ),
     DATE_CREATED,
     Descending
    )

    has to sort on DATE_CREATED, descending if your filter returns data and DATE_CREATED is a Date/Time field in your List ZZQCLTS. Your images show Lot Number - how do you know it is not sorting by date?

     

    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.

    Visit my blog Practical Power Apps

  • agonciulea Profile Picture
    8 on at

    Hi WarrenBlez,

     

    here is a screenshot with and without the date formula in the filter 

     

                   Without Date in Filter                                                   With Date in Filter

     

    agonciulea_2-1646407874053.pngagonciulea_3-1646407882185.png

     

     

     

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Hi @agonciulea ,

    What is your data source here ? If it is Excel, then your dates are Text (I see you already have converted several) and the sort is correct. Try this (Note you can only work with record numbers returned from the top filter up to your Delegation limit)

    With(
     {
     wList:
     Sort(
     Filter(
     ZZQCLTS,
     StartsWith(QC_LOT_NUMBER,LotSearch.Text),
     StartsWith(PART_NUMBER,PartNumSearch.Text),
     StartsWith(COMMERCIAL_PART_NO, CommerialPartSearch.Text)
     )
     )
     }
     Sort(
     AddColumns(
     Filter(
     wList,
     (IsBlank(DatePicker1.SelectedDate) || DateValue(DATE_MANUFACTURED, "EN-us") = DatePicker1.SelectedDate)
     ),
     "DateSort",
     DateValue(DATE_CREATED)
     ),
     DateSort,
     Descending
     )
    )

     

    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.

    Visit my blog Practical Power Apps

  • agonciulea Profile Picture
    8 on at

    Hi @WarrenBelz 

     

    my data source is SQL

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Hi @agonciulea ,

    Your dates are Text if you have to convert them with DateValue() - did you try the code I posted?

     

    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.

    Visit my blog Practical Power Apps

     

     

  • agonciulea Profile Picture
    8 on at

    Hi @WarrenBelz 

    unfortunately the code above did not work. it just errors out.

     

    I have been able to determine its a Date filed issue. If i do a Text() , DateValue() or a Startwith() the sort breaks, but if i do a Date with no formating it appears to work correctly.  but now i cant seem to get the datepicker do work correctly or with filter the date. 

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Hi @agonciulea ,

    As I mentioned, I am not an SQL user, but this document may be of assistance to you.

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 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard