What I would like to do is something like this:
=SUM(A(ROW()):E(ROW()))
so this formula would take a sum of all the elements from column A to E in the current row.
Is this possible or should I take some other approach?
I have a lot of data that depends on the sum in this way and I don't want to waste time by typing for each row some other number so I'm trying to figure out how to GENERALIZE the formula.
Thank you in advance...
Well, if I get what you're looking for exactly, you could maybe use:
=SUM(INDEX(A:E,ROW(),1):INDEX(A:E,ROW(),5))
You could also use the shortcut for autosum: Alt+H+U
Related
I have a Row and the range is B2:B10 and the numbers are from 1 - 9. At random about 1/2 of those numbers will be placed in this Row and need the formula to tell me what numbers are missing. Of course, I can simply look and tell what they are but would like for the formula to let me know. When you ask this question on the Internet it gives the solution for Columns and not Rows. I know this involves an array, but haven't quite mastered that yet.
Thanks.
=TEXTJOIN(",",,IF(ISERROR(MATCH({1,2,3,4,5,6,7,8,9},B2:B10,0)),{1,2,3,4,5,6,7,8,9},"")) should work if a you need a list of numbers not included.
So, for large number it is hard to hardcode numbers in array. You may like this dynamic approach where you do not need to hardcode numbers rather you can just use SEQUENCE() function (if your Excel have it) to define how many numbers you want to check. Try-
=TEXTJOIN(",",TRUE,IF(ISERROR(MATCH(SEQUENCE(20),B2:B10,0)),SEQUENCE(20),""))
3000 Rows of data and need a formula to be applied to calculate percentages in blocks of 4 rows.
I've tried dragging the formula down and playing around with Offeset function, but can't figure out a correct way for doing it.
THANKS EVERYONE FOR YOUR HELP, FOUND A SOLUTION! Looks like I should have mentioned that the counts were weighted so calculations were based off of the actual number not the rounded one displayed.
Use:
=M11/SUM(INDEX(M:M,INT((ROW(1:1)-1)/4)*4+11):INDEX(M:M,INT((ROW(1:1)-1)/4)*4+14))
Here is a solution not using INDIRECT:
=$M11/SUM(INDEX($M:$M,(ROUNDDOWN((ROW(1:1)-1)/4,0)*4)+11):INDEX($M:$M,(ROUNDDOWN((ROW(1:1)-1)/4,0)*4)+15))
This solution assumes that the values in the far left column will always be the same.
=IF(A1="B2",C1/SUM(INDIRECT("C"&ROW(A1)&":C"&ROW(A1)+3)),IF(A1="M3",C1/SUM(INDIRECT("C"&ROW(A1)-1&":C"&ROW(A1)+2)),IF(A1="T2",C1/SUM(INDIRECT("C"&ROW(A1)-2&":C"&ROW(A1)+1)),C1/SUM(INDIRECT("C"&ROW(A1)-3&":C"&ROW(A1))))))
It's long but gives these results.
I want to calculate time difference of a column in Excel, column data shown below:
08:06am-12:00pm
10:40am-11:30am
01:15pm-04:00pm
Please share any formula, reference or method to calculate time difference in Excel column.
This will do it:
=VALUE(MID(A1,9,5)&" "&MID(A1,14,2))-VALUE(MID(A1,1,5)&" "&MID(A1,6,2))
Apply a number format to the cell of hh:mm.
Please try:
=TEXT(LEFT(RIGHT(A2,7),5),"hh:mm")+IF(MID(A2,14,1)="p",1/2,0)-TEXT(LEFT(A2,5),"[hh]:mm")+IF(MID(A2,6,1)="p",1/2,0)-IF(RIGHT(A2,7)="12:00pm",-0.5)
It's pretty simple, actually:
=TIME(HOUR(B2),MINUTE(B2),SECOND(B2))-TIME(HOUR(C2),MINUTE(C2),SECOND(C2))
Where B2 and C2 both have times in them.
What it looks like there is that your column has BOTH times in it. You will have to split those columns first. Because the way you have it, the field will be interpreted as TEXT and nothing else.
I would like to have part of an excel formula be dynamic, other than a cell reference.
For instance, suppose that in column A (cells A1:A99) I have a bunch of numbers, and I want to know how many of those numbers are greater than 50.
If I wanted this calculation to be static, I could simply use one of the following:
=COUNTIF($A$1:$A$99,">50")
=SUM(IF($A$1:$A$99>50,1,0))
=SUM(($A$1:$A$99>50)*1)
I mention all three because my actual formula is hairy and a bit of a mix of the second and the third. (After all, perhaps something will work with COUNTIF but not with the others.)
Now, I want to be able to type my condition in another cell (say C1). So if I type ">50" in C1, my calculation will be as above, but if I type "<100" I will count how many entries of column A are less than 100.
Is this possible? (I am using Excel 2003 on Windows XP.)
There may be something that I'm missing.
If you give
=COUNTIF($A$1:$A$99,C1)
in any cell, and then in cell C1 you type >50 or <100
don't you get what you want?
Use INDIRECT
=INDIRECT(COUNTIF($A$1:$A$99,">50"))
is same as
=COUNTIF($A$1:$A$99,">50")
But, as you identified, the former, you can generate within the excel cells! I do it all the time, for such things.
I usually solve this by adding another column carrying the result of a complex logical expression, like
=AND(OR(C3<D3;E3>=100);A3=VLOOKUP(B3;Sheet2!$A$2:$B$212;2;FALSE))
this formula is in all rows of -say- column F - note: no IF needed here!
then I calculate a complex conditional sum across column E using =SUMIF() like
=SUMIF(F2:F57;TRUE;E2:E57)
I know that some users say "I do not want to change my design. That's ok; my argument is that I have better control over the condition, I can work on the condition seperately from summing up or other functions that rely on that condition, and I can filter records for TRUE or FALSE to look at the subsets and have a rapid overview if the formula makes sense
hope that helps Good luck MikeD
I have a SUM array formula that has multiple nested IF statements, making it very inefficient. My formula spans over 500 rows, but here is a simple version of it:
{=SUM(IF(IF(A1:A5>A7:A11,A1:A5,A7:A11)-A13:A17>0,
IF(A1:A5>A7:A11,A1:A5,A7:A11)-A13:A17,0))}
As you can see, the first half of the formula checks where the array is greater than zero, and if they are, it sums those in the second part of the formula.
You will notice that the same IF statement is repeated in there twice, which to me is inefficient, but is the only way I could get the correct answer.
The example data I have is as follows:
Sample Data in spreadsheet http://clients.estatemaster.net/SecureClientSite/Download/TempFiles/example.jpg
The answer should be 350 in this instance using the formula I mentioned above.
If I tried to put in a MAX statement within the array, therefore removing the test to find where it was greater than zero, so it was like this:
{=SUM(MAX(IF(B2:B6>B8:B12,B2:B6,B8:B12)-B14:B18,0))}
However, it seems like it only calculates the first row of data in each range, and it gave me the wrong answer of 70.
Does anyone know a away that I can reduce the size of the formula or make it more efficient by not needing to repeat an IF statement in there?
UPDATE
Jimmy
The MAX formula you suggested didnt actually work for all scenarios.
If i changed my sample data in rows 1 to 5 as below (showing that some of the numbers are greater than their respective cells in rows 7 to 11, while some of the numbers are lower)
Sample Data in spreadsheet http://clients.estatemaster.net/SecureClientSite/Download/TempFiles/example2.jpg
The correct answer im trying to achive is 310, however you suggested MAX formula gives an incorrect answer of 275.
Im guessing the formula needs to be an array function to give the correct answer.
Any other suggestions?
=MAX( MAX( sum(A1:A5), sum(A7:A11) ) - sum(A13:A17), 0)
A more calculation-efficient (and especially re-calculation efficient) way is to use helper columns instead of array formulae:
C1: =MAX(A1,A7)-A13
D1: =IF(C1>0,C1,0)
copy both these down 5 rows
E1: =SUM(D1:D5)
Excel will then only recalculate the formulae dependent on any changed value, rather than having to calculate all the virtual columns implied by the array formula every time any single number changes. And its doing less calculations even if you change all the numbers.
You may want to look into the VB Macro editor. In the Tools Menu, go to Macros and select Visual basic Editor. This gives a whole programming environment where you can write your own function.
VB is a simple programming language and google has all the guidebooks you need.
There, you can write a function like MySum() and have it do whatever math you really need it to, in a clear way written by yourself.
I pulled this off google, and it looks like a good guide to setting this all up.
http://office.microsoft.com/en-us/excel/HA011117011033.aspx
This seems to work:
{=SUM(IF(A1:A5>A7:A11,A1:A5-A13:A17,A7:A11-A13:A17))}
EDIT
- doesn't handle cases where subtraction ends up negative
This works - but is it more efficient???
{=SUM(IF(IF(A1:A5>A7:A11,A1:A5,A7:A11)>A13:A17,IF(A1:A5>A7:A11,A1:A5,A7:A11)-A13:A17,0))}
What about this?
=MAX(SUM(IF(A1:A5>A7:A11, A1:A5, A7:A11))-SUM(A13:A17), 0)
Edit:
Woops - Missed the throwing out negatives part. What about this? Not sure it it's faster...
=SUM((IF(A1:A5>A7:A11,IF(A1:A5>A13:A17,A1:A5,A13:A17),IF(A7:A11>A13:A17,A7:A11,A13:A17))-A13:A17))
Edit 2:
How does this perform for you?
=SUM((((A1:A5>A13:A17)+(A7:A11>A13:A17))>0)*(IF(A1:A5>A7:A11,A1:A5,A7:A11)-A13:A17))