cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MostafaGamal
Helper III
Helper III

how to filter table based on date selection

Hi all,

I have a "DataTable" that reads from a SP and it contain a column Called "Date" with the type of a "Date" i want to filter this DataTable based on the range of a date in a DatePicker

 

the user can choose and then the DataTable shows only the data in the date the user chose in the DatePicker 

 

Please Help 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @MostafaGamal ,

Still agree with @JacoDeRooij this time. I always use two date picker controls to select a date range. This is not complex in my opinion.

If you Insist on using one date picker, I think you need to use two variables to help you. Something like below, you must click buttons to make the selected date into the specified variable. Then on your gallery, formula should be:

Filter(list,Date>=StartVariable && Date<EndVariable )

valbaimsft_0-1623978173599.png

 

Using two variables to keep date may be redundant for me, so I would recommend you to use two date picker as @JacoDeRooij suggested. 

Filter('list', DateColumn1 => Datepicker1.Selected.Date && DateColumn1 <= Datepicker2.Selected.Date)

Best regards,

Allen

 

View solution in original post

11 REPLIES 11
JacoDeRooij
Helper I
Helper I

I hope I can help you. 

 

In PowerApps is a date picker available. 
In the DataTable where the items should be shown. You can filter the items like this

 

filter(‘sp list’, Date = DatePicker.selected.Date)


In theory it should after selecting a date only show the items with that date.

I’ve you have any questions please let me know.

 

 

kind regards 

Hi,

I use the code you provide and it didnt work 

 

MostafaGamal_0-1623878125713.png

 

 

 

v-albai-msft
Community Support
Community Support

Hi @MostafaGamal ,

Have you selected a correct date(existing in your list)?

Can you provide some screenshots your formula using in the DataTable?

I agree with @JacoDeRooij's view, but I am not sure why this doesn't work for you.

I did a test on my side based on your requirement, and everything works fine.

1. Here is my DataTable1 populated from a SP list called "list10" with a Date column called "BoardDate":

valbaimsft_1-1623897918489.png

2. For helping you find the difference more clearly, I add a second DataTable, and set its Items property to:

Filter(list10,BoardDate=DatePicker1.SelectedDate)

valbaimsft_2-1623898051091.png

Compare with my steps and check if there is any difference with your step.

Let us know if you still have issue.

Best regards,

Allen

Thanks, it works 

but i want to the DatePicker to be a range of date not a one day

Example from 15 June to 17 June 

but the date picker give me only the option to choose one day 

JacoDeRooij
Helper I
Helper I

@MostafaGamal 

I think at this moment the only option is to make 2 Datepickers.

@v-albai-msft Do you have any further ideas to select 2 dates in 1 datepicker without making it unnecessary complex?

 

Your filter formula might be something like this: 

 

Filter('list', DateTime => Datepicker1.Selected.Date And  DateTime <= Datepicker1.Selected.Date)

 

Kind regards

Hi @MostafaGamal ,

Still agree with @JacoDeRooij this time. I always use two date picker controls to select a date range. This is not complex in my opinion.

If you Insist on using one date picker, I think you need to use two variables to help you. Something like below, you must click buttons to make the selected date into the specified variable. Then on your gallery, formula should be:

Filter(list,Date>=StartVariable && Date<EndVariable )

valbaimsft_0-1623978173599.png

 

Using two variables to keep date may be redundant for me, so I would recommend you to use two date picker as @JacoDeRooij suggested. 

Filter('list', DateColumn1 => Datepicker1.Selected.Date && DateColumn1 <= Datepicker2.Selected.Date)

Best regards,

Allen

 

View solution in original post

thanks so much, I have another question 

How i can extract the data in the from the table as an Excel file ? 

Hi @MostafaGamal ,

Do you mean you want to save the filtered data into a Excel file?

If yes, you may consider to create views in SP side, and directly save the filtered SP view.

Best regards,

Allen

Yes that what i want 

How to make views in SP ?

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

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