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 Condition not retur...
Power Apps
Answered

IF Condition not returning expected output

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

 

So I have an edit form component that includes a date picker field and two choice fields. I have a button below my editForm that I run an IF statement on to check against a SharePoint list. My formula for the OnSelect of said button is as follows;

 

 

If(
 CountRows(
 Filter(
 CarBookings,
 Date = DataCardValue5.SelectedDate && TimeRange.Value = DataCardValue3.Selected.Value && SpaceBooked.Value = DataCardValue1.Selected.Value
 )
 ) && DateDiff(
 Now(),
 DataCardValue5.SelectedDate
 ) < 0,
 ResetForm(Form1),
 SubmitForm(Form1); ResetForm(Form1)
)

 

 

 

It would seem however that my second condition with the DateDiff function is not working potentially. Even when the value of the DateDiff function returns a negative number such as -4 for example the form will still submit when I expect it should just reset. This is just basically to reject any date trying to be submitted that is older than the current day. Can anyone suggest why my form is always being submitted despite ;

 

DateDiff(
Now(),
DataCardValue5.SelectedDate
)

 

returning -6 etc.

 

Thanks

Categories:
I have the same question (0)
  • Verified answer
    Bilakanti Profile Picture
    1,226 on at

    @Anonymous In your code you're not comparing the CountRows result, Use below code.

    If(
     CountRows(
     Filter(
     CarBookings,
     Date = DataCardValue5.SelectedDate && TimeRange.Value = DataCardValue3.Selected.Value && SpaceBooked.Value = DataCardValue1.Selected.Value
     )
     )=0 && DateDiff(
     Now(),
     DataCardValue5.SelectedDate
     ) < 0,
     ResetForm(Form1),
     SubmitForm(Form1); ResetForm(Form1)
    )

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 379 Most Valuable Professional

#2
11manish Profile Picture

11manish 203 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard