+ Reply to Thread
Results 1 to 11 of 11

Problem: DateDif, count quarters + IF statements

Hybrid View

berger01 Problem: DateDif, count... 03-16-2012, 01:19 PM
ConneXionLost Re: Problem: DateDif, count... 03-16-2012, 01:42 PM
berger01 Re: Problem: DateDif, count... 03-16-2012, 01:58 PM
DGagnon Re: Problem: DateDif, count... 03-16-2012, 01:46 PM
berger01 Re: Problem: DateDif, count... 03-16-2012, 01:50 PM
ConneXionLost Re: Problem: DateDif, count... 03-16-2012, 01:53 PM
DGagnon Re: Problem: DateDif, count... 03-16-2012, 01:54 PM
ConneXionLost Re: Problem: DateDif, count... 03-16-2012, 02:00 PM
ConneXionLost Re: Problem: DateDif, count... 03-16-2012, 02:05 PM
berger01 Re: Problem: DateDif, count... 03-16-2012, 02:11 PM
berger01 Re: Problem: DateDif, count... 03-16-2012, 02:22 PM
  1. #1
    Registered User
    Join Date
    01-24-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2007
    Posts
    76

    Problem: DateDif, count quarters + IF statements

    Good Day,

    In the attached I am trying to accomplish: (Row 5)

    1. Count How many calendar quarters (3 mo) between columns "H" and "A", IF column F is blank.
    2. IF column "F" is not blank, then count quarters between columns "F" and "A".

    And

    3. IF column "P" is a (1) then I want to subtract 12 months from the count.
    4. IF column "P" is a (2) then I want to subtract 24 months from the count.
    5. IF column "P" is a (3) then I want to subtract 36 months from the count.

    To get the quarters, I am attempting to devide by 4 at the end of the formula.

    Here is what I have so far:

    =IFERROR(IF(OR(AND(P5=1, IF(ISBLANK(F5),DATEDIF(H5,A5,"m"),DATEDIF(F5,A5,"m"))-12,IF(OR(AND(P5=2, IF(ISBLANK(F5),DATEDIF(H5,A5,"m"),DATEDIF(F5,A5,"m"))-24,IF(OR(AND(P5=3, IF(ISBLANK(F5),DATEDIF(H5,A5,"m"),DATEDIF(F5,A5,"m"))-36,)),0)/4

    I'm not even sure if I'm close. any help would be great......

    Thank you
    Attached Files Attached Files
    Last edited by berger01; 03-16-2012 at 02:25 PM. Reason: Correct the Title

  2. #2
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: Problem: DateDif, count quarters + IF statements

    First, you'll need to convert column A from text to date format. Then, try:

    =MAX(0,IF(ISBLANK(F5),DATEDIF(H5,A5,"m"),DATEDIF(F5,A5,"m"))/4-P5*12)
    Cheers,
    Would you like to say thanks? Please click the: " Add Reputation" button, on the grey bar below the post.

  3. #3
    Registered User
    Join Date
    01-24-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Problem: DateDif, count quarters + IF statements

    Thank you. I do see where the other IF Statements have been developed. However the result from the suggested formula is null. This is the one I am trying:


    =MAX(0,IF(ISBLANK(F5),DATEDIF(H5,A5,"m"),DATEDIF(F5,A5,"m"))/4-P5*12)

  4. #4
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Problem: DateDif, count quarters + IF statements

    Try out this formula and see if it is getting the results you are after

    =IFERROR((IF(F5="",DATEDIF(H5,A5,"m"),DATEDIF(F5,A5,"m"))-IFERROR(P5*12,0))/4,"")
    If you liked my solution, please click on the Star -- to add to my reputation

    If your issue as been resolved, please clearly state so and mark the thread as [SOLVED] using the thread tools just above the first post.

  5. #5
    Registered User
    Join Date
    01-24-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Problem: DateDif, count quarters + IF statements

    This looks helpful, thanks. Can you take a shot at the other IF statements:

    3. IF column "P" is a (1) then I want to subtract 12 months from the count.
    4. IF column "P" is a (2) then I want to subtract 24 months from the count.
    5. IF column "P" is a (3) then I want to subtract 36 months from the count.

  6. #6
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: Problem: DateDif, count quarters + IF statements

    That's what the "-P5*12" is doing in the formula.

  7. #7
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Problem: DateDif, count quarters + IF statements

    that should be already included in both mine and ConneZionLost's solutions.

  8. #8
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: Problem: DateDif, count quarters + IF statements

    I used a MAX function to eliminate the return of negative values. If you want to see them then try:

    =IF(ISBLANK(F5),DATEDIF(H5,A5,"m"),DATEDIF(F5,A5,"m"))/4-P5*12
    Cheers,

  9. #9
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: Problem: DateDif, count quarters + IF statements

    Oops, lets try this by subtracting quarters instead of months:

    =MAX(0,IF(ISBLANK(F5),DATEDIF(H5,A5,"m"),DATEDIF(F5,A5,"m"))/4-P5*4)
    =IF(ISBLANK(F5),DATEDIF(H5,A5,"m"),DATEDIF(F5,A5,"m"))/4-P5*4

  10. #10
    Registered User
    Join Date
    01-24-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Problem: DateDif, count quarters + IF statements

    Wow, both of you are awesome. I think I have it now and am just fine tunning. I will post with the final result that works best and mark as solved here in a momement.

    thanks so much.

  11. #11
    Registered User
    Join Date
    01-24-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Problem: DateDif, count quarters + IF statements

    Thanks to both of you, I have used this suggestion with success:

    =IFERROR((IF(F5="",DATEDIF(H5,A5,"m"),DATEDIF(F5,A5,"m"))-IFERROR(P5*12,0))/4,"0")

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1