+ Reply to Thread
Results 1 to 32 of 32

Conditional formatting with multiple criteria

  1. #1
    Registered User
    Join Date
    07-29-2019
    Location
    North Carolina, USA
    MS-Off Ver
    MS Office 2016
    Posts
    14

    Conditional formatting with multiple criteria

    Hello,

    My dataset is as follows:

    Category Total
    Primary 500
    Secondary 200
    Tertiary 300

    I am trying to highlight the total column with three different colors based on the value in the Category and Total columns.

    For example, I want to highlight green if the category is Primary and the total is >= to 500, Yellow if >= to 400, or Red if less than 400.
    I also want to do the same for the Secondary and Tertiary categories with Green, Yellow, or Red, but the determining values would be different.

    I'd like to use icons for the different colors. I was able to do that using one category since I did not have to check what the category was, but with more than one category I haven't been able to do it.

    Is there a way this can be done?

    Thanks

    I missed the discouragement regarding multiple website posting. Here's the URL to the one other location I posted the same request: reddit.com/r/excel/comments/cj6ldq/conditional_formatting_with_multiple_criteria/
    Last edited by Aloupha; 07-29-2019 at 08:00 AM. Reason: Add link to other posting.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Conditional formatting with multiple criteria

    Welcome to the forum.

    You need three rules for the Total column using the cell value option in the CF dialog (see below).

    I am having a bit of trouble visualising what you want for the category.

    A word of caution: be sparing with conditional formatting. Overloading your workbook with it can make it hard to read and will eventually slow the workbook down. Better to use it to pinpoint relevant data rather than to colour-code everything, which is overkill.
    Attached Images Attached Images
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    07-29-2019
    Location
    North Carolina, USA
    MS-Off Ver
    MS Office 2016
    Posts
    14

    Re: Conditional formatting with multiple criteria

    Thanks for the fast response.

    This is a performance spreadsheet for three different teams. Each team has different parameters for being Green, Yellow, or Red. What you have above is what I used when it was just one team.

    So, imagine the requirement being as follow:

    Team 1: Score 500 or above = Green, equal or greater than 400 but less than 500 = Yellow, less than 400 = Red
    Team 2: Score 400 or above = Green, equal or greater than 300 but less than 400 = Yellow, less than 300 = Red
    Team 3: Score 300 or above = Green, equal or greater than 200 but less than 300 = Yellow, less than 200 = Red

    Ideally, I am looking for something like this as the condition to highlight the cell as Green. The formatting condition for cell B2 would be something like this.... =IF($A$2="Primary",500,If($A$2="Secondary",400,300)).

    Causion acknowledged. I used the icons to make it easier to read.

    Attached is what I had working for just one team. But with now three teams, I am just not sure how or if it is doable.

    sample.jpg
    Last edited by Aloupha; 07-29-2019 at 03:13 AM.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Conditional formatting with multiple criteria

    You probably need to set up a lookup table for the teams so that Excel knows which scoring system to use. However, you can't use formulae that refer to lookup tables with icon sets.

    My initial reaction is that you are over-complicating things, and that your resulting workbook will be an overload on the senses.

    I suggest you provide a sample workbook if you need any further help with this.

  5. #5
    Registered User
    Join Date
    07-29-2019
    Location
    North Carolina, USA
    MS-Off Ver
    MS Office 2016
    Posts
    14

    Re: Conditional formatting with multiple criteria

    I am not able to add an attachment for some reason. Maybe because I am new?

    Here's a screenshot of what my workbook essentially looks like.

    screenshot 1.jpg

    I want the cells C2:G11 to change colors (Green, Yellow, Red) as follows:

    screenshot 2.jpg

    A lookup is what I intend to use as soon as I find out how to do the conditions. Then I'll point to the lookup.

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Conditional formatting with multiple criteria

    Yes, you are allowed to attach a workbook.

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

    A lookup is what I intend to use as soon as I find out how to do the conditions. Then I'll point to the lookup.
    But not with icon sets ...

    I have told you how to create conditions. However, with multiple value sets, this won't work, so the CF formula will have to be the lookup. Therefore I cannot tell you how to do the CF until you tell me what the lookup will be. You seem to be getting this a bit muddled.

    The lookup as you are showing it won't work. Attach the workbook, please.

  7. #7
    Registered User
    Join Date
    07-29-2019
    Location
    North Carolina, USA
    MS-Off Ver
    MS Office 2016
    Posts
    14

    Re: Conditional formatting with multiple criteria

    I think I may be misunderstanding you regarding lookup. My screenshot wasn't meant to be a lookup, just a reference of how I want the conditions to behave.

    Could you elaborate or show me an example?
    Last edited by Aloupha; 07-29-2019 at 07:56 AM.

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Conditional formatting with multiple criteria

    Still waiting to see the workbook.

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

  9. #9
    Registered User
    Join Date
    07-29-2019
    Location
    North Carolina, USA
    MS-Off Ver
    MS Office 2016
    Posts
    14

    Re: Conditional formatting with multiple criteria

    See attached.
    Attached Files Attached Files

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Conditional formatting with multiple criteria

    The purpose of a sample workbook is to show us what you want - please add some sample data with the expected formatting manually applied (using colour fills, etc.).

    I am still no closer to being able to visualise what the result of all this should look like. You know because it's in your head, but I don't - sorry.

  11. #11
    Registered User
    Join Date
    07-29-2019
    Location
    North Carolina, USA
    MS-Off Ver
    MS Office 2016
    Posts
    14

    Re: Conditional formatting with multiple criteria

    I am not entirely sure what about the following that is not clear or unable to visualize.

    Team AB: Score 500 or above = Green, equal or greater than 400 but less than 500 = Yellow, less than 400 = Red
    Team CD: Score 400 or above = Green, equal or greater than 300 but less than 400 = Yellow, less than 300 = Red
    Team EF: Score 300 or above = Green, equal or greater than 200 but less than 300 = Yellow, less than 200 = Red

    Imagine Team CD and EF do not exist. The excel is simple. All cells would be Green if its value is greater or equal to 500. If greater or equal to 400 but less than 500, it would be Yellow. If it is below 400, it is Red.

    I am trying to do the same thing but for Team CD and Team EF but with different condition for Green, Yellow, or Red on the same data set using some sort of conditional formula.

    What is missing from the above that I need to provide to make it clear?

    I know Icon sets will not work, but to illustrate what I am trying to do, I used it on the first row of the attached excel, and it does what I want. It can be tested by changing the team name in B2 to CD or EF, and the colors will be what I expect them to be.

    On the real excel, I do not change the team name on the row, but each row represents a record for that particular team. I want to replicate what the first row does usisng whatever formatting possible.

    I hope this clears things up.
    Attached Files Attached Files

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Conditional formatting with multiple criteria

    How many teams will there be in the real workbook?

    Did you try the format painter?

    1. Select C2:G2.
    2. Click Format Painter.
    3. Select C3:G11.
    Attached Files Attached Files
    Last edited by AliGW; 07-30-2019 at 02:03 AM.

  13. #13
    Registered User
    Join Date
    07-29-2019
    Location
    North Carolina, USA
    MS-Off Ver
    MS Office 2016
    Posts
    14

    Re: Conditional formatting with multiple criteria

    I did try the format painter, but for it to work properly I would need to update my if statement that calls for $B$2 to $B2, and then use the format painter. But when I update the if statements, I get this error.

    error.jpg

    If somehow the format painter was able to refer to the team name of its respective row, it would work. But all rows point to $B$2.

    There are three teams for now, but there's potential for more. I twill not be A LOT more, but I expect it to increase to no more than 5.
    Last edited by AliGW; 07-30-2019 at 02:23 AM. Reason: Please don't quote unnecessarily!

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Conditional formatting with multiple criteria

    I do have an idea, but it involves helper columns - is that feasible?

  15. #15
    Registered User
    Join Date
    07-29-2019
    Location
    North Carolina, USA
    MS-Off Ver
    MS Office 2016
    Posts
    14

    Re: Conditional formatting with multiple criteria

    I don't think it should be an issue... if anything, I could hide those columns.

  16. #16
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Conditional formatting with multiple criteria

    You wouldn't need to. Leave it with me - let me see if I can make it work first.

  17. #17
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Conditional formatting with multiple criteria

    OK - so I've mocked up a basic example. The idea is that you have two columns for each day (you could make these look like one with formatting).

    The first column houses a formula that uses the lookup table on the right:

    =IFERROR(--INDEX(Table1[[#Headers],[0]:[3]],MATCH($D2,OFFSET(Table1[[#Headers],[0]],MATCH($B2,Table1[Team],0),0,1,4),1)),"")

    This is then set to use the result of the formula to trigger the icon (which is set to show alone in the cell without the cell contents).

    If you want icon sets, then this is the only way, I think.
    Attached Files Attached Files

  18. #18
    Registered User
    Join Date
    07-29-2019
    Location
    North Carolina, USA
    MS-Off Ver
    MS Office 2016
    Posts
    14

    Re: Conditional formatting with multiple criteria

    Thanks - I like the trick you used. On the real excel, I am using a reference table as well. It'll take me a little time to dissect what you did, but looking at the formula and whatnot, I understand it. The only challenge though is this excel requires sorting on a daily basis, and using two columns per day is workable but may be challenging. Also, this spans over 14 days and repeats (on a new wokrsheet), so it will cause the excel to be wider than I'd like. Screenshots are taken and posted on a daily basis, so the wider the excel the smaller the view has to be adjusted. The length is usually 20 rows of data per team.

    On the bright side, the way you have it is very clean, and having the color indicators separate from the value column is an excellent idea. I will play with the excel to see what works best.

    By the way, I don't have to use icon sets. I am only using it currently because the excel "looks" cleaner with them. I am not opposed to using cell highlights or something else that works. I wasn't able to do it with highlighting the cells either, at least not with the if formula.

    Also, what does this mean?

    rep.jpg
    Last edited by Aloupha; 07-30-2019 at 08:00 AM.

  19. #19
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Conditional formatting with multiple criteria

    That means what it says: you cannot award me any more rep points until you have given some to someone else. Nice thought, but don't worry about it!

    Let us know how you get an. In terms of flagging using just colour, you'd recycle the formula I've used in the helper column within the CF. Let us know if you need any more help.

  20. #20
    Registered User
    Join Date
    07-29-2019
    Location
    North Carolina, USA
    MS-Off Ver
    MS Office 2016
    Posts
    14
    Quote Originally Posted by AliGW View Post
    That means what it says: you cannot award me any more rep points until you have given some to someone else. Nice thought, but don't worry about it!
    That makes no sense, but rules are rules I suppose.


    Quote Originally Posted by AliGW View Post
    Let us know how you get an. In terms of flagging using just colour, you'd recycle the formula I've used in the helper column within the CF. Let us know if you need any more help.
    The reference column is proving to be challenging. Would you mind showing me how it could be done without using icon sets and without the columns?

  21. #21
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Conditional formatting with multiple criteria

    That makes no sense, but rules are rules I suppose.
    It's a measure to prevent artificial inflation of reputations, which has happened in the past. It is what it is - it's the thought that counts. Thanks!

    I will have another look at your issue now.

  22. #22
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Conditional formatting with multiple criteria

    I've just tried to apply the formula to conditional formatting and it is not being accepted. I'll keep playing and see if I can get something to work.

  23. #23
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Conditional formatting with multiple criteria

    I've drawn a blank on this - sorry. I've put out a call for help to the wider community.

  24. #24
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Conditional formatting with multiple criteria

    Quote Originally Posted by Aloupha View Post
    I did try the format painter, but for it to work properly I would need to update my if statement that calls for $B$2 to $B2, and then use the format painter. But when I update the if statements, I get this error.

    Attachment 634880

    If somehow the format painter was able to refer to the team name of its respective row, it would work. But all rows point to $B$2.
    You can get around that by using INDIRECT with R1C1 references.

    By adding a lookup table to the sheet (which could be located in a different sheet to make things look tidy) I've done what you asked for with icon sets using this formula as the rule for the green icons.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    changing the lookup column from 4 to 3 for yellow icons. I've set it up in the attached copy of your file. The values in the lookup table are the minimum for each colour.
    Attached Files Attached Files

  25. #25
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Conditional formatting with multiple criteria

    Thanks, Jason - I hadn't thought of R1C1 references.

  26. #26
    Registered User
    Join Date
    07-29-2019
    Location
    North Carolina, USA
    MS-Off Ver
    MS Office 2016
    Posts
    14

    Re: Conditional formatting with multiple criteria

    Thanks Jason - I downloaded your attachment and saw your changes, but I do not see any difference though. Only the first row is working. The values on B3:B11 have no impact on their corresponding row, and B2 still dictates the behavior of the entire table (C2:G11).
    Last edited by Aloupha; 07-31-2019 at 09:47 AM.

  27. #27
    Registered User
    Join Date
    07-29-2019
    Location
    North Carolina, USA
    MS-Off Ver
    MS Office 2016
    Posts
    14

    Re: Conditional formatting with multiple criteria

    I copied and pasted the formatting formula for green in N2:N11, and the returned values are correct. I did the same for the yellow formula in O2:011, and the returned values are also correct. I changed the team names in B2-B11, and the values from N2:011 changed accordingly. Based on that, I deduce that the formatting SHOULD work, but for some reason it is working.

    Something else I notice is when I use the Edit Formatting rule window for the Green or Yellow condition, even just for viewing purposes, the formula for other disappears.
    Attached Images Attached Images
    Last edited by Aloupha; 07-31-2019 at 11:02 AM.

  28. #28
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Conditional formatting with multiple criteria

    Not sure what is going on there, I'm not getting the same problem with the formula missing from the box.

    I've entered a simple formula,
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    into B2:B11, then used f9 to refresh the sheet and the icons appear to be changing as expected.

    Re-attached file with the above in place, see how it goes, I'll take another look in the morning to see if I can find the issue.
    Attached Files Attached Files

  29. #29
    Registered User
    Join Date
    07-29-2019
    Location
    North Carolina, USA
    MS-Off Ver
    MS Office 2016
    Posts
    14

    Re: Conditional formatting with multiple criteria

    B2:B11 values are changing, and the colors are changing. But they are still based on the value of B2

  30. #30
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Conditional formatting with multiple criteria

    I see what you mean now

    I found a few other ways to bypass the relative reference warning, but the result is still the same.

    With this in mind, I can only see 2 possible options.

    Using similar formulas as conditional formatting rules to change the cell background colour instead of using icons.
    Formula for green would be
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    changing the lookup column to 3 for yellow and using =C2>0 for red.
    The rules should be in order, green, yellow, red. With 'Stop if True' checked for green and yellow. If you get this bit wrong it will probably all go red.

    Or apply an icon rule to each individual row of data instead of one covering the whole table (would be a slow and painful process manually, but should be possible to apply with vba).
    If you want to try this then I'll make up a test file for you later (probably not until friday evening, UK time, but will do before if I get chance).

  31. #31
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Conditional formatting with multiple criteria

    Then there's the approach I suggested back in post #17 - maybe that's not looking quite so infeasible now.

  32. #32
    Registered User
    Join Date
    07-29-2019
    Location
    North Carolina, USA
    MS-Off Ver
    MS Office 2016
    Posts
    14

    Re: Conditional formatting with multiple criteria

    Quote Originally Posted by jason.b75 View Post
    Using similar formulas as conditional formatting rules to change the cell background colour instead of using icons.
    Formula for green would be
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    changing the lookup column to 3 for yellow and using =C2>0 for red.
    The rules should be in order, green, yellow, red. With 'Stop if True' checked for green and yellow. If you get this bit wrong it will probably all go red.
    This works. I'll use light colors to make it less busy and easier on the eye.

    I don't understand why your RICI reference did not work though. It should have worked....

    Quote Originally Posted by jason.b75 View Post
    Or apply an icon rule to each individual row of data instead of one covering the whole table (would be a slow and painful process manually, but should be possible to apply with vba).
    If you want to try this then I'll make up a test file for you later (probably not until friday evening, UK time, but will do before if I get chance).
    thanks - it doesn't need to be that complex. Using the cell highlights will do what I need.
    Last edited by Aloupha; 08-01-2019 at 10:06 AM.

+ 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. Conditional Formatting using IF/AND statements
    By Meteorain in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-03-2017, 08:16 AM
  2. [SOLVED] If-Statements and Conditional Formatting Help
    By lauren.cbj in forum Excel General
    Replies: 10
    Last Post: 01-29-2015, 09:18 PM
  3. If statements with conditional formatting
    By FootwearJunkie in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-23-2014, 09:32 PM
  4. Conditional Formatting with IF and AND Statements
    By ahs004 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-30-2013, 01:00 PM
  5. IF and AND statements in conditional formatting
    By daowen in forum Excel General
    Replies: 7
    Last Post: 07-25-2013, 12:16 PM
  6. If statements or conditional formatting
    By Excel-Access in forum Excel General
    Replies: 4
    Last Post: 07-18-2012, 09:04 AM
  7. Conditional formatting with IF statements
    By LEXmono in forum Excel General
    Replies: 6
    Last Post: 03-20-2012, 10:55 AM

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