If criteria is met, add 2 years, if not, add 1

FV_64

New Member
Joined
Jun 22, 2022
Messages
7
Office Version
  1. 365
Platform
  1. Windows
Hello and Good Morning (or Good Afternoon :))

I need help with inserting a formula in Column D (New Date), that adds 2 years to End date (Column C) when the type = Physician (column A) and adds 1 year to the End date (column C) for all other types in the new column.

Help would be appreciated.
 

Attachments

  • CaptureSample.JPG
    CaptureSample.JPG
    78.5 KB · Views: 8

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Another option:
Excel Formula:
=LET(e,--C2:C12,p,IF(A2:A12="PHYSICIAN",1,2),EDATE(e,p*12))
 
Upvote 0
I believe it was my mistake in not communicating my need, I apologize. With the answers provided, I am seeing that only one year was added.

My expectation was that in Column D, for Physicians it would show 2 years added to the End Date. Ex. D5 should be 4/12/2026, D6 would be 9/10/2026, etc.
 

Attachments

  • CaptureSample1.JPG
    CaptureSample1.JPG
    87.6 KB · Views: 8
Upvote 0
I believe it was my mistake in not communicating my need

No, I think something else is going on:
Book3
ABCD
1
2PHYSICIAN12/04/202412/04/2026
3PHYSICIAN09/10/202309/10/2025
4DENTIST07/03/202407/03/2025
Sheet1
Cell Formulas
RangeFormula
D2:D4D2=EDATE(C2,IF(A2="PHYSICIAN",24,12))


You need to check your cells that contain "PHYSICIAN" to make sure that there aren't any errant spaces or other non printable characters? You can do some testing by using the LEN() formula to check the length of the text in those cells is as you would expect.

If you need more help diagnosing, try to download the XL2BB add-in and post your example data to the forum in a way it can be copied.
 
Upvote 1
Please try:
Excel Formula:
=IF(TRIM(A2)="PHYSICIAN",EDATE(C2,24),EDATE(C2,12))
 
Upvote 1
Or this:
Excel Formula:
=EDATE(C2,12+12*(trim(A2)="PHYSICIAN"))
 
Upvote 0
No, I think something else is going on:
Book3
ABCD
1
2PHYSICIAN12/04/202412/04/2026
3PHYSICIAN09/10/202309/10/2025
4DENTIST07/03/202407/03/2025
Sheet1
Cell Formulas
RangeFormula
D2:D4D2=EDATE(C2,IF(A2="PHYSICIAN",24,12))


You need to check your cells that contain "PHYSICIAN" to make sure that there aren't any errant spaces or other non printable characters? You can do some testing by using the LEN() formula to check the length of the text in those cells is as you would expect.

If you need more help diagnosing, try to download the XL2BB add-in and post your example data to the forum in a way it can be copied.
Yeah, that was the issue. I totally missed I had a bunch of blank spaces. Thanks a lot!
 
Upvote 0
Hello, I got a follow up question. I read the forum rules and I didn't want to create another post as it may seem as duplicate. Apologies if I do need to create a new one. Please advise.

In the original criteria, I missed an important condition. To recap, we added 2 years to End date (Column C) when the type = Physician (column A) and added 1 year to the End date (column C) for all other types in the new column. The formula I'm using is

=IF(TRIM(A2)="PHYSICIAN",EDATE(C2,24),EDATE(C2,12))

The detail I missed: There may be several Physician (Column A) that their Eff (column B) and End Date (column C) have a span of 5 years (see highlighted in yellow as an example). For those (and only those) Physicians that have a span of 5 years between eff date (column B) and end date (column C), I need the date to display in New Date (column D) to be the same as their End date (Column C). Meaning, I don't need it to add the 2 years for only those. Those 3 examples in the image below that are in red, my expectation is to see 02/22/2028, because their eff and end date have a 5 year span. Those other Physicians that have a 3 year date span and that we added 2 years, are fine.

Help is much appreciated.

PS: Yes, I'm in the process of adding the XL2BB add in.

1679494518112.png


TypeEffEndNew Date
NON-EMERGENCY MEDICAL TRANSPORTATION01/19/202201/19/202501/19/2026
NON-EMERGENCY MEDICAL TRANSPORTATION05/05/202105/05/202405/05/2025
OPTOMETRIST02/26/202102/26/202402/26/2025
PHYSICIAN04/12/202104/12/202404/12/2026
PHYSICIAN12/23/202012/23/202312/23/2025
PHYSICIAN07/21/202007/21/202307/21/2025
PHYSICIAN02/22/202302/22/202802/22/2030
PHYSICIAN02/22/202302/22/202802/22/2030
PHYSICIAN02/22/202302/22/202802/22/2030
URGENT CARE CENTER07/03/202007/03/202307/03/2024
PHYSICIAN12/28/202112/28/202412/28/2026
PHYSICIAN12/28/202112/28/202412/28/2026
DENTIST03/01/202103/01/202403/01/2025
OPTOMETRIST09/25/202009/25/202309/25/2024
PSYCHOLOGIST09/25/202009/25/202309/25/2024
MULTI-DISCIPLINARY GROUP05/06/202105/06/202405/06/2025
PHYSICIAN12/16/202212/16/202512/16/2027
PHYSICIAN GROUP05/26/202005/26/202305/26/2024
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,895
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top