cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

If statement filter by date

Hello!

I am having an if statement that filters on what date is selected but it does not work. What am I doing wrong?

Here is the code:

 

Filter(
        Tabel1;
        'Start - Date' = SelectedDate
    )

 

 The start date is formatted like this: 2-7-2020 (dd-mm-yyyy), it is a date column.

Selected date is formatted like this: https://gyazo.com/e5170504ba03ac6ccccc107c124f8331

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Yeah I got this figured out, thank you though @v-siky-msft 

My solution: I made a power automate flow that turned the whole column 'Start - Date' into a date column. I have done that using this formula: 

if(empty(items('Apply_to_each_2')?['Start - Date']),null,addDays('1899-12-30',int(items('Apply_to_each_2')?['Start - Date']),'yyyy-MM-dd'))

At first it would give me an error since I have some empty rows in my file. That's why I added the if statement returning null when the value is empty. 

View solution in original post

11 REPLIES 11
eka24
Super User
Super User

Add the name of the DatePicker:

 

Filter( Tabel1; 'Start - Date' = DatePicker1.SelectedDate )

Or

Filter( Tabel1;Text( 'Start - Date',ShortDate)= Text(DatePicker1.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.

mdevaney
Super User
Super User

@Anonymous

What do you mean by “it does not work.”  Are you getting an error?  Or do no results simply appear with no error?

 

What datasource are you using? If SharePoint, what column type is Start - Date?


---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Anonymous
Not applicable

It is an Excel file and the column is a short date column @mdevaney 

I am getting no errors, just no results

Anonymous
Not applicable

DataPicker is not a value I am using @eka24 

The selecteddate is working. I put a label and then as the text value I put "SelectedDate"

Result: https://gyazo.com/94885e2138b93e946d9591c56b11a540

What does selectedDate represent, a Column name?

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

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.

Anonymous
Not applicable

Since the formula is Onvisible, have you tried navigate to another screen and back.

 

Also if the selectedDate is in a label, put the name of the label4.Text in the formula instead of the variable name.

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

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.

Anonymous
Not applicable

It then takes it as a Text value, which we don't want. It is not compatible @eka24 

The SelectedDate does change whenever I click on another date, so that one works.

Here you can see the SelectedDate is a date value: https://gyazo.com/07f8f04885692909610eb41b0ec9fb84

So the problem is with the Start - Date not being the same format, I guess?

Hi @Anonymous ,

 

Have you got this resolved? If not, I'm happy to help further.

I would suggest you display the 'Start - Date' Value from Excel table to a label by setting Text property to First('Table1').'Start - Date'.

Then you may find that the 'Start - Date' value is DateTime type and the time is 8:00 AM by default, even if the 'Start - Date' is formatted as Date in Excel.

Snipaste_2020-07-31_10-33-15.png

Hence the filter code should be like this:

Filter(Table1,'Start - Date'=DateTimeValue(SelectedDate &" "& Time(8,0,0)))

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 (1,788)