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

Filter Gallery using DateRange filter

Hi All,

 

I am facing an issue when filtering the gallery (Large dataset from CDS) using a date range.


1. I tried like date range of single column and its working fine
             Filter(DataSets,'Valid From'>=DatePicker1.SelectedDate && 'Valid From'<=DatePicker2.SelectedDate )
2. Same like above I want to filter data based on two columns like below, but it's not working

             Filter(DataSets,'Valid From'>=DatePicker1.SelectedDate && 'Valid To'<=DatePicker2.SelectedDate )
Note: Max Date of Valid To column is 12/31/9999 (I updated end year like Today()+10000)

If anyone has any idea please help me with this.

 

Thanks 🙂

10 REPLIES 10
eka24
Community Champion
Community Champion

The two formulas are the same. The one working and the one not working. Please which other column do you want to add.

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

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.

Hi,

Thanks for the reply.
scenario 1 I used both "Valid from" column only, but in second scenario I changed to "Valid To"
1.  Filter(DataSets,'Valid From'>=DatePicker1.SelectedDate && 'Valid From'<=DatePicker2.SelectedDate )
2. Filter(DataSets,'Valid From'>=DatePicker1.SelectedDate && 'Valid To'<=DatePicker2.SelectedDate )

eka24
Community Champion
Community Champion

Try

Filter(DataSets,Text('Valid From',ShortDate)>=Text(DatePicker1.SelectedDate,ShortDate) && Text('Valid From',ShortDate)<=Text(DatePicker2.SelectedDate,ShortDate))

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

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.

Tried below ones 

error_1.png
error_2.png

Filter(DataSets,Text(Value('Valid From'),ShortDate)>=Text(DatePicker1.SelectedDate,ShortDate) && Text(Value('Valid From'),ShortDate)<=Text(DatePicker2.SelectedDate,ShortDate))

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

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.

Hi, Thanks for ur patience and reply.
When I am using the query in the "gallery.Items", it's not working


error_5.png


If I use the same query to display in label its working fine, can you please tell me what will be the issue.


error_3.png

 

Thanking you in advance 🙂

v-siky-msft
Community Support
Community Support

Hi @Sampath_Kumar ,

 

I feel confused with the logic of the second condition, the date of Valid To column is 12/31/9999 which is much greater than selected date, so nothing will return if the condition is 'Valid To'<=DatePicker2.SelectedDate.

Am I misunderstand something?

BTW, The Text does not support greater than and less than comparisons.

 

Sik

Hi,

 

I want to get the data between a selected date range, in that my "Valid To" column max date is 12/31/9999.
So if I give "valid To"=12/31/2050, I should get all records between dates right?
so how can I filter the gallery (large datasets) using date range?

Hi @Sampath_Kumar ,

 

Your filter code is correct, and works properly in my test.

Snipaste_2020-05-20_11-27-22.png

If you select the 'Valid To' data picker to 12/31/2050, you can only get the records that the valid to is less than 12/31/2050.

Please make sure it does exist records that valid to is less than 12/31/2050.

 

If you just want to return all records when selecting 12/31/2050 (since it is the maximum date we can select), please try this:

If(DatePicker2.SelectedDate=DateValue("12/31/2050"),
Filter(DataSet,'Valid From'>=DatePicker1.SelectedDate && 'Valid To'<=DateValue("12/31/9999")),
Filter(DataSet,'Valid From'>=DatePicker1.SelectedDate && 'Valid To'<=DatePicker2.SelectedDate)
)

Hope this helps.

Sik

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 (4,435)