Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Excel searching column multiple conditions

Posted on 2012-04-13
9
Medium Priority
?
164 Views
Last Modified: 2012-04-15
Hi All,

I have a question regarding searching an unordered list of data with multiple conditions. I have attached a file of what I am trying to do.

Essentially I want to search column G, total sales, for the first value that meets 2 (or potentially more) conditions.

In the example i have highlighted in yellow, I am looking to return the first date where the date is greater than April 1 AND the Total Sales exceeds 150.

I have been able to do this with a single condition, highlighted in orange (or whatever you would like to call that color). The formula I am using there is:

=INDEX(Sales[Date],MATCH(TRUE,Sales[Total Sales]>=150,0))

Open in new window


I just can't seem to get this to work with AND statements.

In this example there are 2 conditions, but I may like to include more in the future.

I am just looking for the simplest and most elegant way to do this.

Many thanks in advance
0
Comment
Question by:stokenator
9 Comments
 
LVL 7

Expert Comment

by:karunamoorthy
ID: 37843845
where is the attached file?
0
 

Author Comment

by:stokenator
ID: 37844303
Attached is the sample file - my apologies.

I have highlight the expected result in yellow. many thanks
sample-file.xlsx
0
 
LVL 81

Expert Comment

by:byundt
ID: 37845129
Assuming that there is an answer, you might try an array formula like:
=INDEX(F$2:F$1000,MATCH(1,(F$2:F$1000>=--"4/1/12")*(G$2:G$1000>=150),0))

To array-enter a formula:
1) Select the cell and paste the formula in the formula bar
2) Hold Control and Shift keys down
3) Hit Enter, then release all three keys

Excel should respond by putting curly braces { } surrounding your formula. If not (or if you see #N/A), then repeat steps 1-3.


If you need to verify that there is an answer before returning the date, then try array-entering:
=IF(COUNTIFS(F$2:F$1000,">=4/1/12",g$2:G$1000,">=150")=0,"",INDEX(F$2:F$1000,MATCH(1,(F$2:F$1000>=--"4/1/12")*(G$2:G$1000>=150),0)))

Brad
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 42

Expert Comment

by:dlmille
ID: 37845603
Brad - I just learned something

--"4/1/12" converts to date, like doing DATEVALUE("4/1/12")

A bit cryptic but easy on the typing ;)

Dave
0
 
LVL 81

Expert Comment

by:byundt
ID: 37846154
Dave,
I've been using that short-cut with dates for so long, I forget that it isn't the official way of doing things. :-)         One thing I don't know, however, is how it works for people who have d-m-yy as the default date structure.

Brad


On the original question, I forgot about using IFERROR. Using it will shorten the alternative formula to:
=IFERROR(INDEX(F$2:F$1000,MATCH(1,(F$2:F$1000>=--"4/1/12")*(G$2:G$1000>=150),0)),"")

It still must be array-entered.
0
 

Author Comment

by:stokenator
ID: 37848432
Thankyou so much Brad, that is perfect!

There is one other task that i need to adapt this formula to accomplish and I can't seem to do it. I hope that you're able to assist.

I have uploaded a new version of my sample file. The expected value is highlighted in RED.

After I return the date from the first example, I want to calculate the minimum sales between the 2 dates.

Simply put I want to search the list and return the minimum sales between 2 dates.

I would really appreciate it if you could assist with this as well.

Regards,

Stokenator
sample-file-V2.xlsx
0
 
LVL 81

Accepted Solution

by:
byundt earned 2000 total points
ID: 37848606
Matt,
I see that you put your sales data in a table. That's a good practice, so I rewrote the original formula plus the newly requested one as:
=INDEX(Sales[Date],MATCH(1,(Sales[Date]>=--"4/1/12")*(Sales[Total Sales]>=150),0))   first over 150
=MIN(IF((Sales[Date]>=--"4/1/12")*(Sales[Date]<=B3),Sales[Total Sales],""))    min sales
=INDEX(Sales[Date],MATCH(B5,IF((Sales[Date]>=--"4/1/12")*(Sales[Date]<=B3),(Sales[Total Sales]),""),0))     date of min sales

All of these are array formulas, so remember to Control + Shift + Enter.

Cell B3 contains the results of the first formula. Note you'll need to apply a date format to the result of the third formula.

Brad
0
 

Author Comment

by:stokenator
ID: 37848661
Brad - THANKYOU!

This is brilliant and just what I was looking for.
0
 

Author Closing Comment

by:stokenator
ID: 37848664
perfect solution
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question