+ Reply to Thread
Results 1 to 12 of 12

Formula that Returns a Value under Specific Conditions

  1. #1
    Registered User
    Join Date
    07-15-2013
    Location
    Massachusetts
    MS-Off Ver
    Office 365
    Posts
    8

    Formula that Returns a Value under Specific Conditions

    My problem is that I have some data that was dumped from a database and I need to return values from that data under specific conditions (shown in attachment). Any help you can provide will be greatly appreciated! Thanks!
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    Germany
    MS-Off Ver
    365
    Posts
    491

    Re: Formula that Returns a Value under Specific Conditions

    Sorry, your instructions are not clear to me.
    What does mean: If Void = Y, then no need to look further? Look further to do what exactly?
    And what shall the input be in such case?

    See if the attached is what you have in mind (I think your result in C7 is wrong?)

    Regards
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    07-15-2013
    Location
    Massachusetts
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Formula that Returns a Value under Specific Conditions

    Wow that was SO fast I have attached a new version of file...please see blue text in attached. Thank you SO much...it does appear to do exactly what I need it to....
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    02-10-2019
    Location
    Georgia, USA
    MS-Off Ver
    Office 365
    Posts
    2,831

    Re: Formula that Returns a Value under Specific Conditions

    I'm unclear why you have the results you do. For row 4, why is that "Voided Record"? The date is Feb 1, 2020, which is between Jan 1, 2020 and Dec 31, 2020, which is row 15 which matches the account # of ABC and has a span of 366 and is not voided. So why isn't the answer for Row 4 "Sacramento"?

    Also, why is row 7 "Voided Record"? Account is "DEF" and date is Feb 1, 2019, which equals the account and is between the dates in row 18, where void = "N", so why isn't row 7 Region = "Sarasota"?

    In C2, I entered this formula and got all the answers that I assumed were correct but didn't match yours:

    =IFERROR(IF(INDEX($B$13:$B$20,MATCH(1,($A$13:$A$20=A2)*(B2>=$D$13:$D$20)*(B2<=$E$13:$E$20),0))="Y","Voided Record",INDEX($F$13:$F$20,MATCH(1,($A$13:$A$20=A2)*(B2>=$D$13:$D$20)*(B2<=$E$13:$E$20),0))),"No matching span w/in account")

    Now, this is only for Part 1. I haven't tried tackling Part 2 because I'm not sure if I'm on the right track for Part 1.

  5. #5
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    Germany
    MS-Off Ver
    365
    Posts
    491

    Re: Formula that Returns a Value under Specific Conditions

    @Greg11b: my understanding is that row 4 is voided and not Sacramento because it would duplicate the outcome from row 3.
    Row 7 was indeed a mistake as was clarified above (or rather in the updated workbok) and should be Sarasota as you suggested.
    Row 9 is then voided again because duplicate.

    I agree that the data is not really clear, e.g. there's these span durations of -30 days and only these are marked with Void = Y which seems to make either the Y/N or <=365/366 tests redundant; it does look to me as either a too small sample or not the cleanest data to work with.

  6. #6
    Registered User
    Join Date
    07-15-2013
    Location
    Massachusetts
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Formula that Returns a Value under Specific Conditions

    Hi...so it seems, based on the two responses, that the voids are causing a problem...So, I was thinking, I will just eliminate the void records from my query of the data so no voided records will be included in the database data at all. Am attaching a revised example that I hope makes more sense!
    Attached Files Attached Files

  7. #7
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    Germany
    MS-Off Ver
    365
    Posts
    491

    Re: Formula that Returns a Value under Specific Conditions

    Sorry, I am not clear whether your questions is answered or whether the alterntives provided did in fact NOT give you the solutions you were looking for?

  8. #8
    Registered User
    Join Date
    07-15-2013
    Location
    Massachusetts
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Formula that Returns a Value under Specific Conditions

    Hi, thanks for checking... No, question not answered yet...I think my original data was causing confusion so I added new example in latest attachment (version 4). I think I need to use a combiniation of Index and Match functions perhaps...

  9. #9
    Forum Expert
    Join Date
    02-10-2019
    Location
    Georgia, USA
    MS-Off Ver
    Office 365
    Posts
    2,831

    Re: Formula that Returns a Value under Specific Conditions

    Put this in C2 and copy it down. It gives me all the same answers. see spreadsheet.

    =IFERROR(INDEX($E$13:$E$18,MATCH(1,($A$13:$A$18=A2)*($B$13:$B$18>=365)*($B$13:$B$18<=366)*(B2>=$C$13:$C$18)*(B2<=$D$13:$D$18),0)),IFERROR(IF(INDEX($A$13:$A$18,MATCH(1,($A$13:$A$18=A2)*(B2>=$C$13:$C$18)*(B2<=$D$13:$D$18),0)+1)=A2,INDEX($E$13:$E$18,MATCH(1,($A$13:$A$18=A2)*(B2>=$C$13:$C$18)*(B2<=$D$13:$D$18),0)+1),"no match found"),"no match found"))
    Attached Files Attached Files

  10. #10
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Formula that Returns a Value under Specific Conditions

    Another with array formula:
    Please Login or Register  to view this content.
    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
    Quang PT

  11. #11
    Registered User
    Join Date
    07-15-2013
    Location
    Massachusetts
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Formula that Returns a Value under Specific Conditions

    Thank you so much! that seems to work! And now I've been given enough knowledge to be dangerous ha ha...

  12. #12
    Registered User
    Join Date
    07-15-2013
    Location
    Massachusetts
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Formula that Returns a Value under Specific Conditions

    Hi Bebo, yes, am familiar with array formulas...I was all around it, but just didn't know how to put it together....thanks to all for the wonderful help!

+ 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] Formula that returns value or same cell value based on conditions
    By Lauris K in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 08-30-2019, 02:26 PM
  2. Lookup Formula that returns specific variables
    By tbfla in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-08-2017, 09:12 AM
  3. Formula for multiple conditions only returns values for first condition
    By Kazzza in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-01-2013, 07:36 AM
  4. Replies: 3
    Last Post: 06-07-2013, 02:28 PM
  5. [SOLVED] If(OR)) Formula Returns Value WITH 3 or 4 Conditions
    By realniceguy5000 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-01-2013, 11:31 AM
  6. [SOLVED] Action code when formula returns the specific value
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-31-2012, 08:30 AM
  7. Using two ranges as ONE RANGE in countifs with conditions. Formula returns an error
    By Lifeseeker in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-19-2011, 08:20 PM

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