+ Reply to Thread
Results 1 to 8 of 8

Complex formula which works only when the first IF result is true??

  1. #1
    Registered User
    Join Date
    06-24-2017
    Location
    Tasmania, Australia
    MS-Off Ver
    2010
    Posts
    4

    Complex formula which works only when the first IF result is true??

    Hi guys,

    I am trying to sort weather data to allow charting and have hit a wall with getting the prevailing wind direction for a day.

    {=INDEX(IF(Data!$C$2:$C$20000=A158,Data!$O$2:$O$20000),MODE(IF(Data!$C$2:$C$20000=A158,MATCH(Data!$O$2:$O$20000,Data!$O$2:$O$20000,0))))}

    This formula only works when the "IF" function is true for the first value it tests otherwise it returns a False in the cell. I have verified this by selecting different dates and testing the formula.

    How I think it works.....
    MODE: most common number IF column C (the date logged) in the data worksheet equals the date entered into cell A158, IF TRUE; MATCH: Worksheet data column "O" is the wind direction which is logged every 30 minutes (48 values for the day, totals over 16000 rows so for ease I used 20000). The MATCH is to convert the characters to a number so the MODE function will work.

    The INDEX is used to convert the numbers back to the wind direction values.

    I feel I may have over complicated the formula but I am quite the novice with only the holy bible (dummies guide to.....) and the web at my fingertips.

    I hope I've been clear and if I have not please ask for more info/screenshots.
    P.S. I'm using Excel 2010

    Thanks in advance
    Pic 1.JPG
    Data worksheet.JPG
    Last edited by cowhnica; 06-24-2017 at 03:35 PM. Reason: Screenshots added

  2. #2
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Complex formula which works only when the first IF result is true??

    Both IF-functions are missing the False-part. I think there's the problem.
    E.g. if the first IF-function is false that would render the Index-function to use FALSE as the lookup array. That ain't gonna work.
    Cheers!
    Tsjallie




    --------
    If your problem is solved, pls mark the thread SOLVED (see Thread Tools in the menu above). Thank you!

    If you think design is an expensive waste of time, try doing without ...

  3. #3
    Registered User
    Join Date
    06-24-2017
    Location
    Tasmania, Australia
    MS-Off Ver
    2010
    Posts
    4

    Re: Complex formula which works only when the first IF result is true??

    Is there a way to ignore the "False" results? Or a different function to use that would work?

    I tried a few things that obviously didn't work like 0 and ignore but they didn't work at all.

    The formula works only when the first entry is True
    Last edited by cowhnica; 06-24-2017 at 04:06 PM.

  4. #4
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Complex formula which works only when the first IF result is true??

    Index needs a lookup array and (at least) a row number to do what it's designed for.
    What should the formula do when any of the IFs returns FALSE?
    May be you need a construction like IF(condition, INDEX(lookuparray, rownum,0), alternative value).
    Is it possible for you to upload a cut down version of your workbook? Only need a few rows of data.

  5. #5
    Registered User
    Join Date
    06-24-2017
    Location
    Tasmania, Australia
    MS-Off Ver
    2010
    Posts
    4

    Re: Complex formula which works only when the first IF result is true??

    Thank you for your reply,
    I hoped the formula would simply ignore the false returns which worked if the first IF was true, if the first IF was false then the result was simply false.
    Please be gentle I am doing this as much for an education on excel and to learn as much as I am doing it as a favour to my wife.
    I will have a play with your suggestion in the mean time.
    I've uploaded the workbook.
    Attached Files Attached Files

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Complex formula which works only when the first IF result is true??

    In the upload you had
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    That was testing date (A2) against the wind direction range (Data!$O$2:$O$20000) That needs to be
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Also the workbook takes a very long time to calculate at workbook open as well as when re committing that formula.

    As an alternative try a helper column in column U of 'Data'. The formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Then array enter this formula in B2 of 'Wind Direction' and fill down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    I hoped the formula would simply ignore the false returns which worked if the first IF was true, if the first IF was false then the result was simply false.
    No the first argument (INDEX(IF(Data!$C$2:$C$20000=A2,Data!$O$2:$O$20000)) does return FALSE. That simply changes the content of the resulting array. The resulting #N/As come from failure to MATCH and failure to find a MODE. That is why they do not return FALSE.

    I have wrapped an IFERROR(formula,"") overcome the #N/As. Try IFERROR(formula,FALSE) if it helps.

    I also changed the date formatting in column C 'Data' to match the Afrikaans formatting 'Wind Direction'. It affects nothing in the formulas. It was just a Band-Aid for my head.
    Last edited by FlameRetired; 06-25-2017 at 05:10 PM.
    Dave

  7. #7
    Registered User
    Join Date
    06-24-2017
    Location
    Tasmania, Australia
    MS-Off Ver
    2010
    Posts
    4

    Re: Complex formula which works only when the first IF result is true??

    Thank you sir, a true gentleman! and a dead set legend!!
    You have a way of explaining something complicated to sound simple.

    Next step a radar chart, wish me luck

    PS the date was annoying me as well but as you said it was not effecting anything so I left it alone.

  8. #8
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Complex formula which works only when the first IF result is true??

    You are welcome. Thank you for the feedback, kind words and the added 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. [SOLVED] weekday() result used in an array formula doesn't work. Formula works if i type in date
    By aarco50 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 06-25-2014, 03:25 PM
  2. I need to edit my formula so it displays every second true result
    By PatAlex in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-18-2013, 07:19 AM
  3. [SOLVED] Formula SUMPRODUCT works, now needs some tweaking, to True/False identify TEXT
    By steve08087 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-29-2013, 06:20 PM
  4. Copy formula result as a true value
    By junada0 in forum Excel General
    Replies: 8
    Last Post: 01-25-2010, 04:19 AM
  5. How do I highlight a formula result (IF statment=True)
    By ncgrit in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-17-2006, 02:30 PM
  6. [SOLVED] How do I highlight a formula result (IF statment=True)
    By ncgrit in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-17-2006, 02:25 PM
  7. IF function based on True result with large formula.
    By naiveprogrammer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-10-2005, 07:05 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