cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
YukonJoe
Frequent Visitor

DateAdd Filter not working as expected on a SharePoint Event List

I have an event list in SP that I am trying to have filtered out for only 30 days out from todays date. Formula seems to check out but the results aren't getting filtered the way I'm expecting them to. I'm still getting results from way past the 30 day date range. 

 

Here's my code. 

 

 

 

Filter('Training Dates', 'EventDate' >= DateAdd(Today(),30,Days))

 

 

 

 

YukonJoe_0-1658513457576.png

 

Still learning my way through all this so any help is appreciated.

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@YukonJoe 

Your formula does not specify an end of your range.  So, anything past 30 days will be shown.

 

Please consider changing your Formula to the following:

Filter('Training Dates', 
    EventDate >= Today() && 
    EventDate <= DateAdd(Today(),30,Days)
)

This will return anything from today's date and 30 days out.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

6 REPLIES 6
RandyHayes
Super User
Super User

@YukonJoe 

Your formula does not specify an end of your range.  So, anything past 30 days will be shown.

 

Please consider changing your Formula to the following:

Filter('Training Dates', 
    EventDate >= Today() && 
    EventDate <= DateAdd(Today(),30,Days)
)

This will return anything from today's date and 30 days out.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

That was incredibly helpful. I wasn't understanding how the 30 days part was working i thought the 30 days meant only look at 30 days out from the Today call. I was able to add that to my ClearCollect and am getting the correct data into my collection now! I owe you a drink. 

RandyHayes
Super User
Super User

@YukonJoe 

Yep, that is all it takes.  You can use that formula as-is on the Items property of your gallery as well - unless there is some need to duplicate all your data in-memory in a collection.

 

Glad it was helpful!

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
YukonJoe
Frequent Visitor

Well the end goal was to filter dates for specific classes in a ComboBox, so for me it was easier to just get a collection of the dates for that range rather than filter my final results, which already has a couple filters and as you can see I'm not so good at those lol.

 

The filter on my drop down if you're curios, there are three of those for each class.

 

If(
    DataCardValue7.Selected.Value = "Front Desk Systems Training",
    Sort(
        Filter(
            trDates,
            Title = "Front Desk Systems Training"
        ).EventDate,
        EventDate,
        Ascending
    ),

 

RandyHayes
Super User
Super User

@YukonJoe 

Yeah, you might want to clean those up a bit.  General rule of thumb is to *never* use If statements in your Items properties.  It should be a function that is going to return the table of items you want...normally the Filter (embed your logic in the criteria of the Filter, not outside of the Filter).  This just makes it easier to maintain, troubleshoot, and causes less issues with the app in general.

Keep at it...you'll get there!  Just keep things in PowerApps super simple! 😁 If you find something is taking a lot of formulas and actions to do, then you are going the wrong way - pull back, think it over, and if stumped, post on the forum! 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
RandyHayes
Super User
Super User

@YukonJoe 

Yeah, you might want to clean those up a bit.  General rule of thumb is to *never* use If statements in your Items properties.  It should be a function that is going to return the table of items you want...normally the Filter (embed your logic in the criteria of the Filter, not outside of the Filter).  This just makes it easier to maintain, troubleshoot, and causes less issues with the app in general.

Keep at it...you'll get there!  Just keep things in PowerApps super simple! 😁 If you find something is taking a lot of formulas and actions to do, then you are going the wrong way - pull back, think it over, and if stumped, post on the forum! 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,362)