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 Platform Community / Forums / Power Apps / Filter the gallery by ...
Power Apps
Answered

Filter the gallery by the latest date, or by DatePicker

(0) ShareShare
ReportReport
Posted on by 126

Hello everybody,

 

can someone tell me what I am doing wrong with the following example?

 

If(
 DatePicker3.SelectedDate >= 1;
 Sort(
 Filter(
 'Reports';
 DatePicker3.SelectedDate = 'ReportTime'
 ); 
 Descending
 );
 'Reports'
)

 

There is a SharePoint list with a "ReportTime" column. New reports are created every day so that the bottom entry in the SharePoint list is the most current.

 

In Power Apps I want to query the SharePoint list and filter the returned result by the latest date.

 

So far it looks like the entries are being displayed to me, but the filtering doesn't really work. In the gallery, the oldest entry is at the top, as well as from SharePoint.

 

As if that wasn't enough. There is a DatePicker in the APP. If the user selects a specific date, only the reports with the selected date should be queried or, if no date is selected, then preferably only the last 30 entries from the list (filtered according to the latest "ReportTime").

 

It works, but unfortunately without filtering.

 

regards

Livearus

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

    @Livearus date picker returns something of type Date Value. Do you cannot compare it with a number. You have to compare it with another DateValue like,

    If(date picker. SelectedDate=Today()....

     

  • Livearus Profile Picture
    126 on at

    Okay, I think the following features are needed to achieve my goal. But how is the query compared. I have to admit that I have a bit of a problem with the "IF condition", which will probably apply here.

     

    LastN(Reports;30)
    Filter(Reports;DatePicker3.SelectedDate = 'ReportTime')
    Sort(Reports;'ReportTime';Descending)

     

    First, if the DatePicker3 is not selected, the "Sort" function is executed. The reports are loaded in the desired order.

     

    But only the last 30 may be displayed, instead the "LastN" function.

     

    But if DatePicker3 is selected, the "Fiter" function is carried out.

     

    Can you help me with this?

     

    The functions on their own already lead to the desired result, just not in combination with one another.

     

    regards

    Livearus

  • Verified answer
    CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Livearus Try this,

    If(IsBlank(DatePicker3.SelectedDate),
    	Sort(LastN(Reports;30);'ReportTime';Descending),
    	Filter(Reports;DatePicker3.SelectedDate = 'ReportTime')
    )
  • Livearus Profile Picture
    126 on at

    Hey

     

    sorry about the late reply. Except for one small thing, your suggested solution was correct. Before the "isBlank" function a "!" Had to be added. Guess to check whether the return value is "not empty" instead of checking that it is "empty"?

     

    If(!IsBlank(DatePicker3.SelectedDate),
    	Sort(LastN(Reports;30);'ReportTime';Descending),
    	Filter(Reports;DatePicker3.SelectedDate = 'ReportTime')
    )

     

    regards

    Livearus

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Livearus Glad you got it right!

  • Livearus Profile Picture
    126 on at

    Hmm

     

    I guess I wasn't right after all. "Kneeling and Confusion". I should have tested whether everything works even after selecting a date. Unfortunately not.

     

    The "!" then, contrary to my assumption, does not have the logic to check whether "not empty" instead of "empty". Rather, it simply removes the function of "IsBlank".

     

    Do you or anyone else have another approach to the problem?

     

    regards

    Livearus

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 392 Most Valuable Professional

#2
11manish Profile Picture

11manish 136 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 109 Super User 2026 Season 2

Last 30 days Overall leaderboard