I am trying to get this formula to ignore the times on the data in column D and look up the date to calculate the costs per day, but can't seem to get this working.
I don't know why you are apparently trying to sum B:B from B2; that seems like a circular reference. I believe you are trying to sum E:E.
=sumifs(E:E, D:D, ">="&A2, D:D, "<"&A2+1)
Put this in B2 then drag down:
=SUMIFS(E:E,D:D,"<=" & A2 + 1 - TIMEVALUE("00:00:01"),D:D,">=" & A2)
It works by searching on less than or equal to the last second of the date in A2 (add 1 day then minus 1 second) and greater than or equal to the first second on the date in A2.
Edit: Damn I over complicated that, user11087823 has put a more appropriate answer.
You can use SUMPRODUCT as shown below:
I suggest you read about how dates and times are stored in Excel, as you will note that I used mathematics, and not string functions, to remove the time portion.
Related
Hello I'm wondering if there's a formula equivalent of an for each statement.
I know this would be possible with VBA, but given it's an official report I'd prefer to make it macro-free.
Basically I have a column (let's say A) that contains when an invoice was paid
`
|----------------------------------|
1|DUE DATE (TABLE HEADER, COLUMN A) | (COLUMN B)
|==================================|
2|1/1/2019 | =If any of the due dates are past today, trigger
3|2/5/2018 |
4|4/5/2018 |
Now let's presume we have the current date (22/2/2018) as you can see, none of these are past the due date.
I have a cell in column B with the following formula
=IF(DATEDIF(TODAY(), A2:A4, "d")">0", "All invoices paid in time", "Invoice past the due date found"
Issue is, DATEDIF can only work with individual day, not a range. Technically I could do it with multiple OR formulas -> eg.
=IF(OR(DATEDIF(TODAY(), A2 "d"), DATEDIF(TODAY(), A3, "D")...and so on......
but this would be only viable in my example, not in document with 500 due dates.
Any idea how to exute this?
TL/DR: I'm trying to create a formula, for a cell, that if any of the due dates are before today, i want the cell to trigger to a different value
There is, sort of. Enter the powerful world of arrays:
Suppose your dates are in A1:A3. And the test date is B1. B1 might contain the (volatile) formula =TODAY().
You use the array formula
=IF(SUM(IF(A1:A3 > B1, 1, 0)), 1, 0)
remembering to press Ctrl + Shift + Return to declare this as an array. Essentially the IF is evaluated cell by cell in the range A1:A3. That's remarkably for-each-like.
There are other techniques for this particular case, but the answer I give you is, I think, the pattern that generalises most readily.
Use the MIN() function. If MIN(A:A) is less than TODAY() then at least one item is past due.
Well Technically I found a way to make this work, but this is more of a workaround, rather than proper answer to the formula in question.
If you create a (hidden) column like this
with the formula
=IF(ISNUMBER(DATEDIF(A2, TODAY(), "d"), 1, 0)
Basically, the way DATEDIF works it tries to substract two dates. However, since Excel is not normally capable of getting negative dates (exception with Date System 1904 enabled). If it gets a negative date, it will produce #NUM! error, so the ISNUMBER formula acts like a trigger criteria in this function.
Then we simply create our control cell
With the following formula
=IF(SUM(B:B)>0, "ALERT: " & SUM(B:B) & " invoices are past the due date", "No invoices past due date yet")
The way this works is quite simple. If our datedif triggers, it goes to 1, by adding (SUM) all the triggers together we achieve the amount of the invoices that are past the due date (invoices where the due date triggered). For better illustration:
Now, let's say 2/3 invoices would be past the due date, then it would produce the following result:
Hopefully this helps :)
You can try this array formula:
= OR(A1:A3>B1)+0
I have the following table:
and I'd like to have the total for each player but values are every 3 columns.
As you can see from the picture on the bottom part I wrote what manually I should enter.
For player 1
=SUM(D3;G3;J3...)
Player 2
=SUM(D4;G4;J4...)
and so on. What formula should I use to calculate automatically every 3 columns? I know how the MOD works but on the net I found too many examples each one using different methods and none worked so far. Can anyone help me please or point me to the right direction to understand how it works to get this data since I'll be using this a lot (get value from cell every nth column).
thanks
It looks like you should just be using SUMIFS here:
=SUMIFS(3:3,$2:$2,"TOT")
This will sum every value on row 3 (Player 1) where the value in row 2 is "TOT" (every 3rd column). Put this in cell B18 and just copy down in your column B.
Or, in case you change your column labels, you can refer to cell D2 instead of typing "TOT" in the formula:
=SUMIFS(3:3,$2:$2,$D$2)
Try this, it will total all the cells that occur every 3 columns beginning at column D. Z3 can be increased to any column you require:
=SUMPRODUCT((D3:Z3)*(MOD(COLUMN(D3:Z3)-1,3)=0))
The explanation on how it works can be found here (I advise you to bookmark this site for future references. They have many other helpful formulas and functions).
Applying this formula to your reality should be something like this for Player 1 (Not tested. Adjust the ranges as required):
=SUMPRODUCT(--(MOD(COLUMN(D3:Z3)-COLUMN(D3)+1,3)=0),D3:Z3)
How I see it what I need is =countif(C:C,"datedif(12-09-2015,C:C,"d")>56")
My best guess is that within the datedif brackets I can't enter a date as C:C.
I keep getting an error message or a zero.
What I want to achieve is to have a monthly (1-30/31) table that shows how many people were working on that day that had been there for more than 56 days. So the end table would look something like this:
use array =SUM(IF()) instead of =COUNTIF()
Firs of all create an IF finction that return TRUE when your conditions are met:
in cell F2 put: =IF("20/09/2015"-C2:C12 > 56) and confirm with CTRL+Shift+enter to create an array formula
you should get: TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE
once you know it works as intended, you can just wrap it in a single-cell sum. In cell G2 put: =SUM(IF("20/09/2015"-C2:C12 > 56)) and confirm with CTRL+Shift+enter. You will have a single cell this time, with a result of 3
This should be enough to get you started. In your case I suggest you store the "1,2,3,4,5..." day numbers in results sheet as dates, formatted to display just the day number, and then reference that directly in each countif
I have tried to see if this question has been asked before, but I can't seem to find an answer.
I have a column of cells (>3000 rows), with either a value of 1 or 0 (call this column A). The value will depend on the value in column B (which will contain either a value or nothing). The values in column B are a SUMIFS function based, summing from column C, and based on months in column D.
The values in B are paid out on the first business day of the next month. So, the SUMIFS function will calculate the dates that match the last month. This works well in theory, however, not every first business day is the first day of the month. This leads the SUMIFS function to not include everything in the correct month, and allows for some discrepancy, which, when you are dealing with people's money is not great. Further, this discrepancy is compounded across multiple periods (in some cases, there are over 100 periods, and a discrepancy of $1 in period 1 amounts to nearly $1000 in period 100)
What I am wondering is:
Is there any way that I can tell the SUMIFS function (column B) to stop when the value in column A is 0? This would tell the SUM function start the summing from the current value in column B and continue the function to the cell below the preceding value in column B.
I've seen suggestions that the MATCH function may work, but I can't see how to do this with either COUNT or SUM.
For security reasons, this solution needs to be entered into the cell, and can't be VBA. Also, it can't be too large, as it will need to be replicated across 200 worksheets in the workbook (not my file originally, and I would have done it differently, but that is another story). There is no problem entering another column or two if that is required.
Any help is gratefully appreciated.
EDIT:
Unfortunately, I can't post an image of the screenshot. I've included a similar screenshot (columns are not the same layout, but hopefully it gives the idea) here:
Rates calculations
The SUMIF formula is (for B2)
=SUMIFS(C2:C35,D2:D35,D2-1,A2:A35,1)
This works fine if I want all the values in the month, irrelevant of when the payment was made.
However, what I need the formula to do is:
SUM (C2:C35,D2:D35,D2-1, but stop when the first 0 is encountered in A2:A35)
Thanks
The INDEX function can provide a valid cell reference to stop using a MATCH function to find an exact match on 0.
This formula is a bit of a guess as there was no sample data to reference but I believe I have understood your parameters.
=SUMIFS(C2:index(C2:C35, match(0, A2:A35, 0)), D2:index(D2:D35, match(0, A2:A35, 0)), D2-1)
This seems to be something that will stand-alone and not be filled down so I have left the cell addresses relative as per your sample(s).
Suppose, in Excel, I have a formula =$C$8+1, what must I add to the 1 such that when I drag, it becomes $C$8+2?
Can this be done?
Below is my actual formula.. I wish to increment 1 to 2 such that it becomes =2
IF((NOW()-$C8)=1,"1","0")
Well.. there might be several ways to do it, but the only one I have in the top of my head is using the =ROW() function.
Let's say you're starting the formula at row 5.
=IF((NOW()-$C8)=ROW()-4,"1","0")
The =ROW() will return the row number you currently are (i.e. 5, in this case). Thus, in the first row we'll have =1 (from 5-4) and then =2 (6-4) and so on.
Still, it seems you're comparing dates, right? I'd say you'd need to truncate the values to have a day comparison between them...
=IF((TRUNC(NOW())-TRUNC($C8))=ROW()-4,"1","0")
Hope it helps... or at least give you a path to chose your solution.