cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Resolver I
Resolver I

Filter SharePoint list by within 12 hours of Item Creation time

Hi,

I would like to filter my ComboBox to show only items on it's SharePoint list datasource that were created in the past 12 hours. This is what I have so far:

Filter(SPList,(Now()-Created)<12)

Any help appreciated, thanks.

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Community Champion
Community Champion

Re: Filter SharePoint list by within 12 hours of Item Creation time

Hi @rhiheu ,

Different issue, same problem - SharePoint calculated fields are not delegable.

You need an actual numeric column in SharePoint populated each time you change the date then create a Variable for today in that format and test against that.

 

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.

View solution in original post

Highlighted
Resolver I
Resolver I

Re: Filter SharePoint list by within 12 hours of Item Creation time

Hi @WarrenBelz, thanks, I've done that now and it's working well. To summarise:

I created a SharePoint column called 'CreatedDate' which is just a 'Single line of text' column, which has a default (calculated) value of:

=TEXT(TODAY(),"yyyymmdd")

It doesn't fill for old entries on the list, but entries added since adding the formula correctly add today's date. I didn't realise there was such a big difference from Power App's perspective between standard columns that have a default calculated value, and calculated columns.

I then used the following formula in the Power App gallery to filter on this, to only show items from today:

Filter(SPListName, CreatedDate=Text(Today(),"[$-en-GB]yyyymmdd")

Thanks again for all your help and perseverance with this.

View solution in original post

19 REPLIES 19
Highlighted
Community Champion
Community Champion

Re: Filter SharePoint list by within 12 hours of Item Creation time

Try:

Filter(SpList,Hour(Now())-Hour(CreatedDate)<8)
Or
Filter(SpList,Hour(Now())-Hour(CreatedDate)<12)
Or
Filter(SpList,Hour(Now())-Hour(CreatedDate)>8)
------------

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

Re: Filter SharePoint list by within 12 hours of Item Creation time

Thanks for your reply. Sorry for having both 8 and 12 in my initial question, it was a typo, I've edited that now.

I've tried this one:

Filter(SpList,Hour(Now())-Hour(CreatedDate)<12)

But the 'Hour(CreatedDate)' part has a red line - it says 'The function 'Hour' has some invalid arguments.'

Is it because I don't have a 'CreatedDate' column? In SP I'm trying to reference the 'Created' column, which is currently in the DD/MM/YYYY HH:MM format.

Highlighted
Community Champion
Community Champion

Re: Filter SharePoint list by within 12 hours of Item Creation time

Try:

Filter(SpList,Hour(Now())-Hour(DateValue(CreatedDate))<12)

------------

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

Highlighted
Resolver I
Resolver I

Re: Filter SharePoint list by within 12 hours of Item Creation time

Hi @eka24 sorry that didn't work either - same error.

Highlighted
Community Champion
Community Champion

Re: Filter SharePoint list by within 12 hours of Item Creation time

Can you give a screenshot

------------

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

Highlighted
Resolver I
Resolver I

Re: Filter SharePoint list by within 12 hours of Item Creation time

Sure:

created filter.jpg

 

Highlighted
Community Champion
Community Champion

Re: Filter SharePoint list by within 12 hours of Item Creation time

@rhiheu ,

You will get a Delegation warning on this (Created is not Delegable), but if you have less than 2000 items in your list and increase your limit to this, this will work

Filter(
   YourSPListName,
   DateDiff(
      Created,
      Now(),
      Hours
   ) <12
)

 

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.

Highlighted
Resolver I
Resolver I

Re: Filter SharePoint list by within 12 hours of Item Creation time

Thanks @WarrenBelz for your reply. Unfortunately I will have more than 2000 items, is there a way to do this with delegation?

Highlighted
Community Champion
Community Champion

Re: Filter SharePoint list by within 12 hours of Item Creation time

Thanks @rhiheu ,

You could do it with a "shadow" time & date field (you can hide it on the form) with a Default value of Now(). It will write the current data as soon as the record is created. You can then use the formula I gave on this field.

 

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.

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,740)