Advanced Data Validation Techniques in Excel [spreadcheats]

Share

Facebook
Twitter
LinkedIn

Data validation is a great way to keep your users informed about possible values in a cell and guide them to select something appropriate. As part of the spreadcheats series, in this post we will discuss 2 advanced data validation techniques that can help you when you are modeling a complex worksheet.

Problem 1: You have 2 lists of possible values and you want a way to switch between both

PS: Many thanks to Alex who proposed this idea and solution through e-mail.

You have a cell where user can enter any value from 2 lists. But you don’t want to overload the in-cell drop down list with tons of values, and rather prefer a simpler approach like this:

data-validation-switch-lists

Solution: Use an IF() formula in validation criteria

validation-criteria-if-formulaThe solution is to use an if() formula to determine which one of the two ranges should be used to validate cell contents.

  • Select the cell where you want to have this type of validation
  • Go to menu > data > validation
  • In the criteria area, select “allow” as “list”
  • In the source area, specify a formula like this: =IF($B$7="Full List",Full-list-range,Partial-list-range)

That is all, you now have a data validation list that can change its source based on user preference.

Problem 2 : You would like to change a list’s values based on what is selected in another list

data-validation-change-listsPS: Many thanks to Catherine for asking this question through email

You have a status tracking spreadsheet where each employee enters the status for each of the projects they are working on. They enter the status by first selecting the department and then selecting a project (from that department).

So how do you do this in Excel?

Solution: Use OFFSET and MATCH to determine which range to use

Remember the offset() and match() formulas we discussed in the last spreadcheats?  Assuming the list of projects for each department is in a range B10:C22 with column B having the department name and column C having the project name and the list is sorted on column B, we can use offset() and match() combination along with countif (ahem!) to determine which range to use for project cell drop-down.

  • For the department cell, we can use simple list validation with values as “Marketing, Ops, Sales, IT”
  • For project cell, go to data validation (menu > data > validation) and specify a formula like this:
    =OFFSET(C9,MATCH($B$6,$B$10:$B$22,0),0,COUNTIF(B10:B22,$B$6),1)
  • What is above formula doing? It is fetching a sub-range from the by finding where the first entry for the selected department is, returning x number of rows from that point, where x = no. of projects in that department.

That is all. You now have a list drop-down that changes values based on what is selected in an earlier cell.

Still having doubts?

Feel free to download this example workbook containing a tutorial on Advanced Data Validation in Excel and poke around to learn.

Facebook
Twitter
LinkedIn

Share this tip with your colleagues

Excel and Power BI tips - Chandoo.org Newsletter

Get FREE Excel + Power BI Tips

Simple, fun and useful emails, once per week.

Learn & be awesome.

Welcome to Chandoo.org

Thank you so much for visiting. My aim is to make you awesome in Excel & Power BI. I do this by sharing videos, tips, examples and downloads on this website. There are more than 1,000 pages with all things Excel, Power BI, Dashboards & VBA here. Go ahead and spend few minutes to be AWESOME.

Read my storyFREE Excel tips book

Overall I learned a lot and I thought you did a great job of explaining how to do things. This will definitely elevate my reporting in the future.
Rebekah S
Reporting Analyst
Excel formula list - 100+ examples and howto guide for you

From simple to complex, there is a formula for every occasion. Check out the list now.

Calendars, invoices, trackers and much more. All free, fun and fantastic.

Advanced Pivot Table tricks

Power Query, Data model, DAX, Filters, Slicers, Conditional formats and beautiful charts. It's all here.

Still on fence about Power BI? In this getting started guide, learn what is Power BI, how to get it and how to create your first report from scratch.

11 Responses to “Who is the most consistent seller? [BYOD]”

  1. Hui... says:

    The Date column in the sample file is Text not Dates

  2. Great Chandoo. Keep it up, Looking forward more from BYOD..

  3. gayani says:

    Thanks

  4. Frank Tonsen says:

    With Excel 2013 the pivot table could be connected to the data model which provides a distinct count.

  5. Mak says:

    This will do for invoice count
    =COUNTIF(F:F,H12)
    Instead of
    =COUNTIFS(sales[SELLER],$H12)

  6. Alejandro says:

    Excellent document. How did you make the last graphic? Witch app. Thanks for answer.

  7. Chris says:

    Can someone tell me what =countif(sales[date],sales[date]) is counting? The value is 19. Its found in the =SUMPRODUCT(IF(sales[SELLER]=H12,1/COUNTIFS(sales[SELLER],H12,sales[date],sales[date]),0))

    • Vândalo says:

      Hi Chris,

      =countif(sales [date],sales[date]) function is counting the unique dates in the table.

      Vândalo

  8. Nguyen says:

    Excellent document!

    Can you explain more about the calculation on Weighted consistency? More specific the small number is 0,00001 ?

    How come the number should be smaller if there is more sellers?

  9. TS says:

    Hi,

    Not understood this formula: {=SUMPRODUCT(IF(sales[SELLER]=H12,1/COUNTIFS(sales[SELLER],H12,sales[date],sales[date]),0))}

    Please explain.

    Thanks.

Leave a Reply