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 / Help with IF with Date...
Power Apps
Answered

Help with IF with DateDiff syntax

(0) ShareShare
ReportReport
Posted on by 27

Hello everyone,

 

some help if possible with the following case:

 

What i have: 
2 Date pickers (Start and End date)

ComboBox1  with values (Pending , Approved)

Combobox2 with values (Draft,Active,NearExpiration,Expired)

 

I cannot come up with the correct syntax so to have simultaneously IF's so to set 2 Comboboxes:

If Datediff  Start,End = 0 then ComboBox1=Approved, ComboBox2=Expired

If Datediff Start,End<=14 then ComboBox1=Approved , ComboBox2=NearExpiration

If DateDiff Start,End>14 then ComboBox1=Approved , ComboBox2=Active

 

Any suggestion or logic to achieve the result will be much appreciated

 

Regards to all and Stay Healthy

 

Categories:
  • Verified answer
    CU-18081211-6 Profile Picture
    9,272 Moderator on at

    Hi @LTEVA ,

    Each comboboxes has to be set separately on DefaultSelectedItems property similar to:

    For ComboBox2:

    If (DateDiff(Start,End,Days)=0, "Expired", DateDiff(Start,End,Days)<=14,"NearExpiration","Active")

    For ComboBox1:

    "Approved"

     

    Hope  it helps !

  • WarrenBelz Profile Picture
    156,754 Most Valuable Professional on at

    Hi @LTEVA ,

    Some syntax guidance here

    With(
     {
     wDiff:
    	 DateDiff(
     Start,
     End,
     Days
     )
     },
    	UpdateContext(
     {
     varDiff,		 
     If(
     wDiff=0,
     "Expired"
     If(
     wDiff<=14,
     "NearExpiration",
     "Active"
     )
     )
     }
     )
    );
    Reset(ComboxBox2)

    The DefaultSelectedItems of ComboBox2 would be

    varDiff

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

     

  • LTEVA Profile Picture
    27 on at

    Hi @ gabibalaban,

     

    Based on your solution i've made some slight modifications to adjust to my data and it worked Perfect!!

     

    Many thanks

     

     

  • LTEVA Profile Picture
    27 on at

    Hi @WarrenBelz ,

     

    thanks for the suggested formula.

    I gave a try on this but got some errors.

     

    Please clarify if i should give this on the DefaultSelectedItems of ComboBox1.

     

    Thanks again.

     

  • WarrenBelz Profile Picture
    156,754 Most Valuable Professional on at

    @LTEVA ,

    I assumed you have solved this - mine was just a different approach

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 271

#3
Mohsin Ali Profile Picture

Mohsin Ali 239

Last 30 days Overall leaderboard