Conditional date formatting in numbers

Hi, I am trying to set up a numbers spreadsheet, that has a list of, names, ages derived from their birthdays, and birthdays.


Name | Birthday in format, 3 Letter Month 2 digit Day, 4 digit Year | Age


The age is computed using the formula


IF(ISDATE(D9),DATEDIF(D9,TODAY(),"Y"), "")


So row would look like


Joe Blogs | Jul 21, 1947 | 76




So I like to colour the age cell


if the birthday is between Jan 1st of the current year and todays date - 15 days, colour the cell light orange

if the birthday is between birthday todays date -14 days and today date -1, colour the cell dark orange

if today is the birthday colour the age cell green

if the birthday is between todays date +1 day and +14 days, colour cell dark red

if the birthday is between +15 days and the 31st of December of the current year, colour cell light red


This is for a table with 20,000+ rows


Thank you for any assistance


Mac mini (M1, 2020)

Posted on Dec 29, 2023 4:01 PM

Reply
7 replies

Dec 30, 2023 8:34 AM in response to dozzzzy

dozzzzy,


I've worked out a solution that I think is close to your requirement. Here is an example. The five columns on the right, E through I, are intended to be hidden because they are intermediate calculations. Hiding them or not is your decision.


As you can see, I formatted the calculation called "Nearest Birthday", not the Age Cell. This is because it is much easier to add a conditional format to a cell that contains the actual conditional test value. It would't be impossible to Conditionally Format the Age Cell, but it's a lot more work.


Next I calculated numeric values for Year, Month and Day for the D.O.B., for use in later expressions.






Now I calculate the Age in Years.




Next I calculate the Date of the most recent birthday, the Last Birthday.




At this point I could proceed to determining the Nearest Birthday, but for clarity I first calculated the Next Birthday. I could have saved a column, but another column's expressions would have become slightly more complex.




Getting near the end here, I calculate the Nearest Birthday, the one closest in time to today's date.




Nothing left to do but apply the Conditional Formatting to the Nearest Birthday Date Cell.




Please remember that it was December 30 when I did this, so that date is the one that will be green in the example.


I hope this will suit your need.


Regards,


Jerry

Dec 29, 2023 8:50 PM in response to dozzzzy

Hi dozzzzy,


That seems like a lot of complex rules for Conditional Highlighting.

Apply those rules first in tables. Then we can work on ways to apply Conditional Highlighting to the Age column.

Here is a start. Use another table "Calculations":



Formula in "Calculations" A2 is DATE(YEAR(TODAY()),MONTH(Table 1::D2),DAY(Table 1::D2))

Formula in "Calculations" B2 is A2−"15d"

And so on in other columns through your other rules.


BTW, I am having trouble understanding your rules 🤔.


Regards,

Ian.

Dec 30, 2023 6:57 AM in response to Jerrold Green1

This is what it sounds like they are wanting to do.

I think the tests are worded a little odd for me, but what I think they are trying to do is a sliding color scale to tell them how far away the birthday is.


if it’s more than fifteen days, light orange

if it’s less than fifteen days, but not today, dark orange

if it’s today green

two weeks overdue (I.e. your forgot even with a spreadsheet!?) dark red

more than two weeks overdue light red.


i would just make a column doing that calculation (day difference) and put a very simple set of conditional format on that column.


jason

Dec 30, 2023 4:38 PM in response to Yellowbox

Yellowbox, thank you so much for you time and effort. I'll definitely try out your solution, and just see how complicated and crazy I can get. I stipulated the range from Jan 1st to today - 15 for reasons I cant quite make sense of now, but they sure felt reasonable at the time. So I think I drop that constraint for, if the birthdate is earlier than today() - 15d and the other extreme if the birthdate is later than today() + 15d as you've done


Thank you

Dec 30, 2023 4:49 PM in response to Jerrold Green1

Jerry, OMG Thank you for so much effort. As I said in response to Yellowbox, I'll definitely drop the jan 1st and dec 31st constraints as you did, I have no idea now why those constraints were even there they seem totally irrelevant and pointless now. I'll go through your solution and Yellowbox's to implement a much cleaner and clearer solution than what I was envisioning. Thanks

Dec 30, 2023 5:00 PM in response to dozzzzy

dozzzzy


Thanks for the feedback. I did have some thoughts about how you will be using the table. Mainly, if you are going to have 20K entires, it could be time-consuming to get to the interesting part. A lot of scrolling. If you began the "Nearest Birthday" at -15, you could sort on that column and have much less scrolling to get to the current date, which otherwise would be in the middle of the list.


It was an interesting project to program.


Best regards,


Jerry

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Conditional date formatting in numbers

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.