cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KVarlow
Helper I
Helper I

DateAdd formula with IF Statement not working

Hi There

I have 3 SharePoint cols:

Date Exposed - date/time (DC59) (ThisItem.'Exposure Date or Date of first test')

Iso Period - Choice 5,7,10,14 (DC66) (ThisItem.'Quarantine/Isolation Period(days)')

End Iso date - date/time (DC71) (ThisItem.'End Iso')

 

According to the selection in DC66, I need to add number of days to the "Date Exposed" field and save in ""End Iso date"

 

I am using the below formula in DC71 DefaultDate

If(ThisItem.'Quarantine/Isolation Period(days)'.Value = "5",DateAdd(DataCardValue59.SelectedDate,5,Days))......

 

I do not get any errors but nothing happens. I am also trying add multiple if statements for each value in DC66 using "&&", "Or" or ";"

Can you provide guidance of where I am going wrong?

 

KR

K

1 ACCEPTED SOLUTION

Accepted Solutions
shoog
Super User
Super User

@KVarlowAre you trying to run this calculation when entering data (before saving it back to the SP list)?

In that case, the values selected won't be in the ThisItem object yet and you should use the datacard instead.

The formula would then be something like:

DateAdd(
   DataCardValue59.SelectedDate,
   Value(DataCardValue66.Selected.Value), 
   Days
)

View solution in original post

10 REPLIES 10
WarrenBelz
Super User
Super User

Hi @KVarlow ,

Firstly the formula for the 'End Iso Date' could simply be

DateAdd(
   DataCardValue59.SelectedDate,
   Value(ThisItem.'Quarantine/Isolation Period(days)'.Value), 
   Days
)

Where are you using this and what else are you trying to add?

 

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.

Visit my blog Practical Power Apps

KVarlow
Helper I
Helper I

Hi Warren

I'm using this in a PA form for the SharePoint list.

So the formula above will cover all choices from the ' Quarantine/Isolation Period(days)'  field in the Iso End date field?

I just added the formula to the DefaultDate field "End Iso date" and it just added the "Date Exposed" , ignoring the "Quarantine/Isolation Period(days". Myaybe I'm doing something wrong here. I need the End Iso Date = (Date exposed + Iso period)

Hi @KVarlow ,

Yes - assuming the 'Quarantine/Isolation Period(days)' field is a Choice field and all choices are numbers stored as Text.

 

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.

Visit my blog Practical Power Apps

 

 

Thankyou for the guidance but it still is just copying the "exposed date" into the field.

When you says "stored as text", what do you mean? 2 = Two

Hi @KVarlow ,

I was referring to your initial post where you are using

ThisItem.'Quarantine/Isolation Period(days)'.Value = "5"

which suggests it is a Choice column (in this type the choices are actually Text). Is this the case?

I copied a suggested formula from a forum,  which used the  quotes around the number.

Then I guess the choices are numbers so I shouldn't use the quotes

shoog
Super User
Super User

@KVarlowAre you trying to run this calculation when entering data (before saving it back to the SP list)?

In that case, the values selected won't be in the ThisItem object yet and you should use the datacard instead.

The formula would then be something like:

DateAdd(
   DataCardValue59.SelectedDate,
   Value(DataCardValue66.Selected.Value), 
   Days
)

Whoa!

Works a treat

Thankyou all for your feedback. 

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,536)