In simple words, we have to find the range that has the lookup value.
Now, the problem is similar to between formula trick we discussed a few days back, yet very different.
We all know that,
- XLOOKUP formula looks up a value in a table and returns the corresponding value in next column
- MATCH formula looks up a value and tells the position of it in a list
We can use XMATCH:
Since we just want to know which row will contain the value, we can use XMATCH as shown below.
=XMATCH(1, (B6:B15<=C3)*(C6:C15>=C3))
Ok, go ahead, I will give you a minute to soak in the awesomeness of that formula.
Are you back?, well, lets explore what this formula does.
How this works:
- C3 contains our lookup value
- B6:B15 has the lower boundary
- C6:C15 has the higher boundary
- The (B6:B15<=C3)*(C6:C15>=C3) returns a bunch of 1s or 0s. It will be 1 whenever C3 is between column B&C values and 0 otherwise.
- XMATCH will match the first 1, ie the first row that matches the range.
Or even the SUMPRODUCT
Then I thought, “may be SUMPRODUCT formula would work for situations like these?!?”
After playing for a while, I got the perfect formula for this.
- Assuming the value to be looked up is in cell
C3 - The start and end values are in
B6:B15andC6:C15respectively,
We write,
=SUMPRODUCT((B6:B15<=C3)*(C6:C15>=C3),ROW(B6:B15))-5
There are 3 portions in that formula,
(B6:B15<=C3)*(C6:C15>=C3)part: This is checking the range B6:B15 and C6:C15 to find that one set of start and end values that would contain the value in C3. The output would be a bunch of 0s with probably a single 1ROW(B6:B15)part: This just gives running numbers from 6 to 15. When you SUMPRODUCT this with above you get a single number corresponding the row in which the match occurred-5part: We reduce the output value by 5 since our value began in row 6, not row 1.
Use this to lookup date ranges too:

As you can guess, you can easily use the above SUMPRODUCT formula to lookup matching date ranges too a la vlookup for date ranges.
Download Range Lookup Example Workbook:
In the download workbook, you can find both examples (values and dates). Go ahead and download it. Play with it to understand range lookup formula better.
Click here to download the sample workbook.
Do you face range lookup problem?
Often, when working on project planning, I end up checking where a date falls between given set of start and end dates. Earlier, I used helper columns to solve such a problem. But the XMATCH (or SUMPRODUCT) solution above is much more elegant and scalable. Plus it is much more fun to write.
What about you?
Do you face range lookup problem often? How do you solve it? Share your techniques and tips using comments. Thank you 🙂

















25 Responses to “Display Alerts in Dashboards to Grab User Attention [Quick Tip]”
I prefer the red,grey,light grey,black icon set. I've also used in-cell pie charts from Fabrice's Sparklines for Excel as an alert which could also provide another piece of information.
I prefer the red,grey,light grey,black icon set. I've also used in-cell pie charts from Fabrice's Sparklines for Excel as an alert which can also provide another piece of information.
For Excel 2007, your formula should do the same as the Excel 2003 version, so that non-alert rows are blank - if they are 0, the unnecessary green icon will show
Hi Chandoo,
Nice Post !! just to add something for EXL 2003, we can also 4 Ifs and link to the alert data
For Ex: If we have alert data in Cell A2 and want to split in 4 orders namely <25%, 25-50%, 50-75% and 75%< then we can following formula and put fonts as you have suggested :
=IF(A2<0.25,CHAR(153),IF(A2<=0.5,CHAR(155),IF(A2=0.76,CHAR(152)))))
And then using Conditional Formating we can dashboard reflected on different COLOURS as per their respective alert.
Best Regards
Rohit1409
Hi Chandoo,
Nice Post !!! just to add something for EXL 2003, we can also 4 Ifs and link to the alert data
For Ex: If we have alert data in Cell A2 and want to split in 4 orders namely <25%, 25-50%, 50-75% and 75%< then we can following formula and put fonts as you have suggested :
=IF(A2<0.25,CHAR(153),IF(A2<=0.5,CHAR(155),IF(A2=0.76,CHAR(152)))))
And then using Conditional Formating we can dashboard reflected on different COLOURS as per their respective alert.
Best Regards
Rohit1409
The Complete formula [Don't Know how it got cut ]
=IF(A2<0.25,CHAR(153),IF(A2<=0.5,CHAR(155),IF(A2=0.76,CHAR(152)))))
PS : Use in single line [I have split it to avoid cuts 😉 ]
Hi Chandoo..
why it is not displaying the complete formula..
anyways here is the balance
"=IF(A2<0.25,CHAR(153), IF(A2<=0.5,CHAR(155), IF(A2=0.76,CHAR(152)))))"
@Rohit... your formulas are fine. Just that the width of comment area is fixed and hence my website is cropping it at 640pixels. I just edited your formula and added few white spaces so that it wraps nicely.
Very good idea btw.. kudos!
Hi,
Maybe just go for 'bold' ; 'underline' or 'italic' to draw the users attention? Those methods (if those can be called methods) are used cross media type (books, journals, blogs, billboards, ...) to guide the readers eye to valuable information.
Just a basic thought
@Tom.. good idea..
[...] has a very nice writeup on how to add such alerts to dashboard sheets. Possibly related posts: (automatically generated)Divide your data set into workbooksHow to enforce [...]
Hi Chandoo,
You certainly grabbed my attention! although I wasn't sure what my brother (Suresh) and cousin (Shyam) were doing right, and I was doing wrong? 😉
I love your blog btw - Many thanks for all your hard work in unravelling the secrets and mysteries of Excel!
Best regards
Ramesh
I thought I saw an advertisment for a book about learning excel called excel himalaya or something. It cost about 35.00 us money but seemed to have the things I need to have my admin assistant to start to use. I was hoping to start with this book and then send her to school if she shows some interest and aptitude. Any help on this would be appreciated. Thanks
Great web site and information!!!!
@Jeff... checkout http://chandoo.org/wp/2010/08/25/excel-everest-review/
thanks, your website is awesome!
[...] Alerts to highlight focus areas [...]
[...] There are lots of numbers in this dashboard. I would suggest adding few more visualizations like showing indicators or applying conditional formatting or replacing a table with a chart. This would reduce the [...]
[...] is the same technique as alert icons in dashboard. Just that I also showed green [...]
[...] is the same technique as alert icons in dashboard. Just that I also showed green [...]
Hi Chandoo
Firstly thanks for all the cool tips on how to use Excel better.
I am new to the site and have a question which you may be able to assist with but dont know if these comment boxes are the best way of asking ?
I am looking at assets and trying to calculate the depreciation total by taking a year (say 2010) adding the expected life of the asset (say 10 years) then comparing that to a future date (say 2015) using an IF statement. The calculation in normal is - IF((year in col B (2010) plus 10years)>year 2015, add a years depreciation, otherwise leave blank). The converted date value does not appear able to add 10 years in order to compare it to 2015. Am I missing something ?
I use the “IF” Statement in conjunction with Conditional Formatting in MS Excel to give verbiage to alert one of a required action, dependant on a review date. This makes a visual stimulus, plus it clues one as to what the conditional format is trying to warn you about and what follow-up actions are required.
Wow, I'm really impressed with dashboards. I had no idea this stuff was even possible with excel. I'd like to offer an interactive dashboard to my customers, showing analytics of their data. I have a .pdf file with the datapoints. I'd like them to enter the data on my website, and be able to see their data. Is something like that possible.
Hi Chandoo,
I've recently purchased the package for both templates.
In the portfolio dashboard,under the calculations worksheet, I'm attempting to change the date range in the gantt chart to show only the range of the project that starts in late 2013. How do I do this?
Thanks
Adam
[...] is the same technique as alert icons in dashboard. Just that I also showed green [...]
Hi Chandoo,
I'm new at Excel Dashboard and found your blog really useful and helpful! It's very nice of you that you dedicate your time to do this.
Could you please explain how can I use Alerts based on dates on a Dashboar?
For example, if a target date is coming closer to the actual date, the alert is yellow or red.
I'd really appreciate some help!
Thank you
Where can I download the file Excel of Averall Statistics ???
Thanks a lot.