cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

Help with IF with DateDiff syntax

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Memorable Member
Memorable Member

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 !

View solution in original post

5 REPLIES 5
Highlighted
Memorable Member
Memorable Member

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 !

View solution in original post

Highlighted
Super User III
Super User III

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.

 

Highlighted

Hi @ gabibalaban,

 

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

 

Many thanks

 

 

Highlighted

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.

 

Highlighted

@LTEVA ,

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

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (13,015)