cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Magnus
Level: Powered On

Filter a list in PowerApps by date

Hi!

I'm just getting started with PowerApps and have created an app based on a Sharepoint list, in which the user can enter upcoming events with a date picker. The app shows all list items by default (both future and past), but I want it to show only entries for tomorrow, today and the past seven days. I can't seem to figure out how to write the code for this filter.

 

This is the default code in the Browse Screen: 

SortByColumns(Filter('Events VU'; StartsWith(Header; TextSearchBox1.Text)); "Title"; If(SortDescending1; Descending; Ascending))

 

The column I want to filter from is called "Startdate", but other than that the sorting above is just fine. How do I pull this off? Or am going about this the completely wrong way? Thanks!

19 REPLIES 19
Super User
Super User

Re: Filter a list in PowerApps by date

Hi @Magnus,

SortByColumns(Filter('Events VU'; StartDate>Today()-8 && StartsWith(Header; TextSearchBox1.Text)); "Title"; If(SortDescending1; Descending; Ascending))
Magnus
Level: Powered On

Re: Filter a list in PowerApps by date

Hi!

Thanks! I tried that code but then I end up with the following warning (translated from Swedish):

 

Delegation warning. The marked part of this formula might not work correctly with the column Startdate on large data sets. The data source might not be able to process the formula and might return an incomplete data set. Your application might not return correct results or behave correctly if the data set is incomplete.

 

In the code view, the word Startdate is underlined in blue. Also, the list in the app shows up empty even though there are events with startdate today. Something wrong with the formatting perhaps?

Super User
Super User

Re: Filter a list in PowerApps by date

Hi @Magnus,

How many items are in your list?

Magnus
Level: Powered On

Re: Filter a list in PowerApps by date

Hi @Drrickryp

Just seven items right now. I've read that there could be problems with large lists but since this list will never be larger than about 100 entries, I don't think that's the problem.

Super User
Super User

Re: Filter a list in PowerApps by date

@Magnus,

You can safely ignore the warning then. To test where the problem is, take out the StartsWith() function and see if your list filters on the start dates alone. Also I noticed that in my formula I had StartDate and not Startdate.

Magnus
Level: Powered On

Re: Filter a list in PowerApps by date

Hi again @Drrickryp,

I tried changing the code to:

SortByColumns(Filter('Events VU'; Startdate>Today()-8)

I still get the same error message, complaining about the column Startdate. Also an empty list in the app. I can't really figure out why. Do I have to declare that the column Startdate is in the list Events VU or is that implicit?

Super User
Super User

Re: Filter a list in PowerApps by date

There has to be a column named Startdate in the list.  It has to be a date type column.  I tested it on my end and it works fine.  Please make sure that the Column name in the formula matches the actual column name in PowerApps.  Sometimes PowerApps renames SharePoint columns.  The way to test is to open a new screen and put a Datatable control on it. In the flyout on the right, Click the Data Source at the top and select Events VU.  The datatable will populate with all of the columns,  go to the column with the startdates and in the far right column, copy the actual name of the column.  In the case of my app, the actual control name was different from what was shown in the datatable. tempsnip.png

 

Community Support Team
Community Support Team

Re: Filter a list in PowerApps by date

Hi @Magnus,

Could you please share more details ahout the error message within your formula?

Which date time format is the Startdate column in your app? Is it a date time value? "mm/dd/yyyy" or "dd/mm/yyyy"?

I have made a test on my side, and don't have the issue that you mentioned. Please check if you have renamed the Startdate column in your SP list. In other words, please check if you have referenced proper Date column name within your formula.

You could review the Data Filed value related to this Date column within your Edit form, check if you have referenced proper date column name.

In addition, please also consider take a try with the following workaround:

Set the Items property of the Gallery control to following:

SortByColumns(
Filter(
'Events VU';
StartsWith(Header; TextSearchBox1.Text);
Text(Startdate, "mm/dd/yyyy") > Text(Today()-8,"mm/dd/yyyy") /* <-- Modify formula here */
);
"Title";
If(SortDescending1; Descending; Ascending)
)

 

Above formula may cause a Delegation issue, in order to fix this Delegation issue, please take a try with the following workaround:

Set the OnVisible property of the first screen of your app to following:

ClearCollect(RecordsCollection, 'Events VU')

Set the Items property of the Gallery to following:

SortByColumns(
Filter(
RecordsCollection;
StartsWith(Header; TextSearchBox1.Text);
Text(Startdate, "mm/dd/yyyy") > Text(Today()-8,"mm/dd/yyyy") /* <-- Modify formula here */
);
"Title";
If(SortDescending1; Descending; Ascending)
)

Note: The Delegation issue is not an error, it just prompt that you could not delegate the processing of data to your SP list data source. If the amount of your SP list records is not more than 2000, you could ignore this Delegation issue.

More details about the Delegation in PowerApps, please check the following article:

Delegation

More details about the Text function, please check the following article:

Text function

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Magnus
Level: Powered On

Re: Filter a list in PowerApps by date

Hi @Drrickryp,

Yes, there is a column by that name and it is a date type column. I also checked that the name matches the actual column name in Sharepoint.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, August 21st at 8am PDT

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

SixthImage

Power Summit Australia 2019

August 20-23rd 2019

Users Online
Currently online: 41 members 4,162 guests
Please welcome our newest community members: