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.
Solved! Go to Solution.
@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()....
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.
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') )
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?
Learn how to create your own user groups today!
Check out the new Power Platform Community Connections gallery!
Congratulations, the new Super User Season 2 for 2021 has started!
Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.