+ Reply to Thread
Results 1 to 7 of 7

Complicated If Then Else Nested Statements

  1. #1
    Forum Contributor
    Join Date
    08-10-2015
    Location
    Sarasota, FL
    MS-Off Ver
    MS 365
    Posts
    77

    Complicated If Then Else Nested Statements

    I have my head spinning and getting lost in nested if then else statements......you guys have always straightened it out....

    I have attached a sample spreadsheet with data and the yellow colored cells are where the formulas would go, with a sample of the expected results.

    I need to calculate the length of stay (LOS) of each client (each row) over a course of a number of years, based on the First Carelog Date and the Last Carelog Date, but I need to know total LOS per year

    so for LOS FY13 I'm looking at (I think): If B1 >= 1/1/13 and C1 <= 12/31/13 then c1-b1 ELSE if b1 < 1/1/13 and c1<=12/31/13 then c1-1/1/13 = so the answer is either a number greater than 1 and less than 365 or the number is 365 or blank

    I need to calculate this across for each year.

    In the example: Row 2 for LOS Fy13 e2 is 310 because it is less than 365 days, but for F2-j2 the answer is nothing because the end date was in 2013
    but in Row 3 e3 and f3 is 365 because they were with us for the full year of those years, but g3 is 9 because they left us on 1/9/15 (and we do need to count the day that is listed in c1)

    Similarly, if the date in column b began in 2015, then e and f would be empty...

    Clear as mud?

    I have tried to figure out the easiest way to do this for weeks, after I figured out that I wasn't getting the right results the way we'd been doing it for years :| The raw data that I get out of my software doesn't make this easy.

    Thank you for suggestions.
    Attached Files Attached Files

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Complicated If Then Else Nested Statements

    If you change the values in the header rows to 13, 14, 15, etc and use a format in those cells of "LOS FY"0, you can use this simple formula

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor
    Join Date
    07-14-2017
    Location
    Poland
    MS-Off Ver
    Office 2010
    Posts
    528

    Re: Complicated If Then Else Nested Statements

    Test my formulas from the attachment.
    Regards.
    Attached Files Attached Files

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Complicated If Then Else Nested Statements

    Maras - sorry for off-topic interjection:

    Although there is no official rule regarding this behaviour, we request that wherever possible both the question AND the answer be provided in substantive detail here within the thread. An attached workbook is an excellent aid for posing a question and offering a solution, but solely doing that with no in thread explanation makes it difficult for researchers to understand or consider the Q & A of this thread without downloading what may be a pointless doc to them, if they can do that at all. Doing that also hides the content from search engines so others may never benefit from this.

    I'm sure you understand, and we look forward to seeing you post your formulas/macros in your posts for the searching benefit of all.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Complicated If Then Else Nested Statements

    Quote Originally Posted by Bob Phillips View Post
    If you change the values in the header rows to 13, 14, 15, etc and use a format in those cells of "LOS FY"0, ... <snip> ...
    If for some reason you can't / don't want to change the titles of the header rows, you can amend Bob's formula like this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Regards,
    Aardigspook

    I recently started a new job so am a bit busy and may not reply quickly. Sorry - it's not personal - I will reply eventually.
    If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark this Thread as Solved'.
    If you use commas as your decimal separator (1,23 instead of 1.23) then please replace commas with semi-colons in your formulae.
    You don't need to give me rep if I helped, but a thank-you is nice.

  6. #6
    Forum Contributor
    Join Date
    08-10-2015
    Location
    Sarasota, FL
    MS-Off Ver
    MS 365
    Posts
    77

    Re: Complicated If Then Else Nested Statements

    Thank you Bob and Aardigspook - it is working as I need it too - and saves me from the nesting nightmare.....

  7. #7
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Complicated If Then Else Nested Statements

    You're welcome and thanks for the rep.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. complicated multiple nested IF statements
    By cduval in forum Excel General
    Replies: 3
    Last Post: 10-05-2017, 01:05 PM
  2. [SOLVED] Nested if statements containing multiple and statements
    By John M. in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-22-2014, 11:48 PM
  3. Complicated Nested IF with OR & AND
    By concatch in forum Excel General
    Replies: 10
    Last Post: 02-07-2012, 11:41 AM
  4. Multiple nested IF statements and AND statements
    By TonyGetz in forum Excel General
    Replies: 2
    Last Post: 12-14-2010, 03:07 AM
  5. Excel 2007 : Complicated if statements needed
    By excel_help_needed in forum Excel General
    Replies: 3
    Last Post: 08-21-2010, 10:42 AM
  6. Nested If statements / logic statements
    By Brainless_09 in forum Excel General
    Replies: 3
    Last Post: 06-17-2009, 02:59 PM
  7. Replies: 12
    Last Post: 05-15-2009, 08:38 AM

Tags for this Thread

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