Date in a formula

I have a SUMIF formula with a date of day. Each cell has a different day. Is there a way to copy or populate all of the cells easily? Also can it be changed easily for each year? So my goal here is to have a daily total based on a date in another spreadsheet for a whole year. Currently I'm doing by day for a week and thought doing a full year would be better. Thanks in advance.


iPad Pro, iPadOS 13

Posted on Oct 10, 2020 9:46 PM

Reply
17 replies

Oct 11, 2020 3:40 PM in response to BigOleOak

Hi BOO,


Several questions regarding your table and formula.

  • I do not see columns with the header labels "Date" and "Pay". Where are these columns located?
  • Where is the formula shown in the screen shot located? My assumption is cell D4 of the table shown in the screen shot.
  • What result does the formula return? If my assumption above is correct, If it shows a red error triangle, it would be useful to know the contents of the error message flagged by that triangle. (Click the triangle once to show the message, then select and copy the message and post it in your reply.
  • Do the cells showing $0.00 contain a similar formula?


Regarding 'easily populating' all of the cells, the answer is probably 'Yes, but…"

The details of the 'but…' part depend upon the answers to the questions above.


"[M]y goal here is to have a daily total based on a date in another spreadsheet for a whole year."


In Numbers, the term "spreadsheet" is short for "spreadsheet document," and refers to the whole document contained in a single Numbers file. Each document contains one or more Sheets, and each Sheet may contain one or more Tables.


If your goal can be restated as "[M]y goal here is to have a daily total based on a date in another Table (in the same spreadsheet document) for a whole year," then your goal is likely achievable.

If you do mean 'in another spreadsheet document)' it is not achievable with a formula, as Numbers formulas in one document cannot reference cells in a different document.


More to come following your reply to the question above.


Regards,

Barry


Oct 11, 2020 7:12 PM in response to Barry

Yes, the formula is in D4 as well as all the other cells in that sheet. Each cell represents a day of the year. You will notice that in cell B6 is the first data in that row, that is because Jan 1, 2021 is on a Friday. I did use the wrong wording as far as spreadsheet vs sheet. The data is on another sheet in this document and I'm attaching a picture of that. So that is the sheet that I am making into a form so it will be easy to fill out on my phone. And that sheet will be where I log all of my trips for the year. I hope this makes things more clear.

Oct 15, 2020 1:05 PM in response to BigOleOak

I believe Barry means that if you are searching for a date formatted as Dec 28, 2020, the dates you are searching should be in the same Mon DD, YYYY format.


A couple of other ideas to check:


Ensure the numbers in your "Pay" column are formatted as currency, not text. I'm not sure I'd trust "automatic" either. Text will not SUM, even if that text looks like numbers. It will add/subtract, etc. with the +,-, etc operators but will not be included in the SUM functions.


Ensure all the dates in all the tables have the time 12:00:00AM. That is the default if you enter a date with no time but it is something to check anyway. If there is a time other than 12:00:00AM, that date will not match.


Ensure all the dates in all the tables are formatted as dates, not as text. I think Numbers converts them internally but why give one more reason for it to not work.


Oct 15, 2020 4:39 PM in response to Badunit

Ok guys I sure appreciate all the help. I have made some headway tonight. So as you can see I am getting my dollar figures in column B. I did change the formula slightly to make it work. Im showing the formula below the first picture.



Now when I copy that row to the next row it is changing my test value and sum value. I tried to copy and paste as well as dragging the yellow dot that is in the center of my selection. I have attached pictures showing the first column with the formula and the second column with the formula after the paste of the formula from the first column.

Any help to resolve the final piece of my problem will be very helpful.

Oct 15, 2020 9:59 PM in response to BigOleOak

"When you say express both sets of dates are you saying from Dec 28, 2020 - Jan 3, 2021?"


No. I'm referring to the set of dates in column C of the "Log" table and the set of Monday dates in row 1 of the Summary table.


See Badunit's description in the first paragraph of the post above.


Badunit's other points are well-taken as well.


Regards,

Barry

Oct 11, 2020 4:37 PM in response to BigOleOak

The way you have it arranged makes it a little complicated. You need to determine the date from the text you have in row 1. This means parsing it to obtain to the starting date. The dates in the column are then calculated by adding the row number - 2 to the starting date.


The formula for the highlighted cell (D4) would be

=SUMIF(DATE, DATEVALUE(REGEX.EXTRACT(D$1,".+?(?=-)"))+ROW()−2, PAY)


If you modify your table and put only the date of Monday (1/11/21 versus 11/11/21 - 1/17/21), it could be simplified to

=SUMIF(DATE, DATEVALUE(D$1)+ROW()−2, PAY)

or

=SUMIF(DATE, D$1+ROW()−2, PAY)


A few words of caution:

  1. It is probably best if you compare dates to dates or text to text, not a mix. The formulas above create date&time values. I do not know if the cells in your "Date" column are text or actual date & time values.
  2. With date & time values, 1/13/2021 6:00PM is not the same at 1/13/2021 12:00AM. If you enter a date with no time, the default time is 12:00AM so this probably is not a problem but it is something to be aware of.
  3. If you get a date wrong in row 1, you may not catch your error. You might consider adding another row that checks that the starting date you typed is actually a Monday. Not necessary but might be useful.


Oct 12, 2020 12:21 AM in response to BigOleOak

Much clearer.


Badunit's post contains most of what I was expectin to say after your clarification, so you'll probably find the rest of this post a bit repetitive.


Rename the Table 1 shown in you most recent post as "Log" (or something similar), using a name that is not repeated on any other table in the document. A short and distinct name keeps formulas shorter and easier to read.


For the example, I'll name the table shown in your first post "Summary".

For the most part, I'll show data in only thise cells involved in the calculations.


Your Log table and Summary table will look like this:

The formula below the Summary table is entered in Cell B2, then filled down to B7 and right for as many columns as yo have weeks.


Here is the same formula in text form, which can be copied and pasted into the formula editor for Summary::B2, then filled to the rest of the cells in the table.


Summary contains one more formula, entered into C1 and filled right for as many columns as needed:

C1: B1+7


Note that all dates shown in the table are Date and Time values with only the Date part entered and only the Date part displayed. All dates used should be displayed using the same format.


Dates in each column of Row 1 of Summary, including the date in B1, are the Monday date at the beginning of that week.

The formula in the rest of the cells in row 1 adds seven days to the date in the column to it's left.


Regards,

Barry

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.

Date in a formula

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