cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PVLove
Helper III
Helper III

Revise DateDiff Formula

Morning @phipps0218  and @WarrenBelz ,

You both helped me resolve my DateDiff issue and your solutions are working perfectly! However, another option, Work Travel, was added to the 'Reason for Request' Choice column. My Ops Manager does not want Work Travel calculated as PTO. When Work Travel is selected the '# of Days Requested' field should remain 0 or blank. I have tried adding the If statements below, but none work as needed. I've added them to the beginning of the formula, middle and end and no change. Can I incorporate this request into the existing formula or would it be better to create a separate field for the Work Travel option?

Thanks again for your help!

Patti

 

Existing formula on Default property of the '# of Days Requested' field:

If(
IsBlank(dcStartDate.SelectedDate) || IsBlank(dcEndDate.SelectedDate),
0,
With(
{
wHol: Filter(
CalHolidays,
HolidayDate >= dcStartDate.SelectedDate && HolidayDate <= dcEndDate.SelectedDate
)
},
RoundDown(
DateDiff(
dcStartDate.SelectedDate,
dcEndDate.SelectedDate,
Days
) / 7,
0
) * 5 + Mod(
5 + Weekday(dcEndDate.SelectedDate) - Weekday(dcStartDate.SelectedDate),
5
) - CountRows(wHol) + 1
)
)

 

If statements I've tried to incorporate into the existing formula:

  • If(LeaveReason.Selected.Value = "Work Travel", "DaysRequested", 0)
  • If("Work Travel" in LeaveReason.Selected.Value,true,false, 0)
  • If(LeaveReason.Selected.Value, "Work Travel"),true, 0)

paPTODates5.png

1 ACCEPTED SOLUTION

Accepted Solutions
phipps0218
Super User
Super User

If(LeaveReason.Selected.Value = "Work Travel", 0, If(
IsBlank(dcStartDate.SelectedDate) || IsBlank(dcEndDate.SelectedDate) && LeaveReason.Selected.Value <> "Work Travel",
0,
With(
{
wHol: Filter(
CalHolidays,
HolidayDate >= dcStartDate.SelectedDate && HolidayDate <= dcEndDate.SelectedDate
)
},
RoundDown(
DateDiff(
dcStartDate.SelectedDate,
dcEndDate.SelectedDate,
Days
) / 7,
0
) * 5 + Mod(
5 + Weekday(dcEndDate.SelectedDate) - Weekday(dcStartDate.SelectedDate),
5
) - CountRows(wHol) + 1
)
)


Just check there is enough brackets but this should work.

Please Accept as Solution if it solves your question. Or just give it a Thumbs Up if it is helpful as can help others.

LinkedIn: https://www.linkedin.com/in/charlie-phipps-%F0%9F%91%A8%E2%80%8D%F0%9F%92%BB-91338715b/
YouTube: https://www.youtube.com/channel/UChmFBGU1YKIU91sNMQ7buGg
Twitter: https://twitter.com/phipps0218

View solution in original post

3 REPLIES 3
phipps0218
Super User
Super User

If(LeaveReason.Selected.Value = "Work Travel", 0, If(
IsBlank(dcStartDate.SelectedDate) || IsBlank(dcEndDate.SelectedDate) && LeaveReason.Selected.Value <> "Work Travel",
0,
With(
{
wHol: Filter(
CalHolidays,
HolidayDate >= dcStartDate.SelectedDate && HolidayDate <= dcEndDate.SelectedDate
)
},
RoundDown(
DateDiff(
dcStartDate.SelectedDate,
dcEndDate.SelectedDate,
Days
) / 7,
0
) * 5 + Mod(
5 + Weekday(dcEndDate.SelectedDate) - Weekday(dcStartDate.SelectedDate),
5
) - CountRows(wHol) + 1
)
)


Just check there is enough brackets but this should work.

Please Accept as Solution if it solves your question. Or just give it a Thumbs Up if it is helpful as can help others.

LinkedIn: https://www.linkedin.com/in/charlie-phipps-%F0%9F%91%A8%E2%80%8D%F0%9F%92%BB-91338715b/
YouTube: https://www.youtube.com/channel/UChmFBGU1YKIU91sNMQ7buGg
Twitter: https://twitter.com/phipps0218

@phipps0218 

Worked like a charm, thank you so much!

Patti

Anytime!

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (3,850)