web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / If statement filter by...
Power Apps
Answered

If statement filter by date

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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

Categories:
I have the same question (0)
  • eka24 Profile Picture
    20,925 on at

    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 Profile Picture
    29,991 Moderator on at

    @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."

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

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

    I am getting no errors, just no results

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    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

  • eka24 Profile Picture
    20,925 on at

    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.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    It is a variabele that I use to click on my agenda app:

    https://gyazo.com/65278b20ebab7322446f413efefdc203

    https://gyazo.com/6314ca176070b33e4aabf672bae29965

  • eka24 Profile Picture
    20,925 on at

    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.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    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?

  • v-siky-msft Profile Picture
    Microsoft Employee on at

    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 

  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    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. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 638

#2
Haque Profile Picture

Haque 317

#3
WarrenBelz Profile Picture

WarrenBelz 315 Most Valuable Professional

Last 30 days Overall leaderboard