Is there a way to write this using formulas.
=Max(a, a+b, a+b+c, a+b+c+d, a+b+c+d+e+...)
I don't want to use VBA for this task and I am not sure how to approach this problem.
Excel sheet expanded with formula
Excel sheet contracted without formula
Objectives:
1) For each of the peoples, (Bill, Ben, Katy), I would like to compare the maximum of the sum of only X through time.
For example, in Column J, I would like to know the current Max of the sum of X. Current is the date 1/17/19 because it is the most recent entry.
2) For each of the peoples, (Bill,Ben, Katy), I would like to compare the max of the previous entry to the max of my most recent entry.
For example, in Column K, I would like to compare the Max of the sum of X at 1/5/16 to the max of the sum of X at 1/17/16.
3) I would like Column J and K to recalculate as I bring in new data entries into Column I. As of now, using a solution mentioned below, in Column J, I think I would be using something like this formula:
=MAX(MMULT(0+(ROW(B9:I9)>=TRANSPOSE(ROW(B9:I9))),B9:I9)
This solution seems to work if I only have X's going down vertically though.
Also, as new data gets brought in, Column J and K would be pushed to the right, becoming Column K and L.
4) The highlighted region in Column I and J are my output sections that are dependent on the date of Cell B1.
For example, if I were to change the date to 1/1/2016 in Cell B1, Cell I7 would equal -4 Cell J7 would equal True.
If I were to change the date to 1/17/16 in Cell B1, Cell I7 would equal 5 and Cell J7 would equal True.
I've been playing around with this a bit, trying to use SUMIFS to pick up sum of X based on a date criteria.
I thank everyone in advance for all your help, and I apologize if my wording to this problem is unclear. I am a undergraduate student, and have no background in computer/programming/anything of that sort at all. Thank you so much!
Assuming a, b, c etc are in a column, then a standard approach will be to use an additional column with a cumulative sum of the values in the input column. Then you can just take the MAX of the column with the cumulative sum.
E.g. use of cumulative sum in column B with the input values in column A:
With MAX formula in column C:
Assuming data in A1:A5, you can use this array formula**:
=MAX(MMULT(0+(ROW(A1:A5)>=TRANSPOSE(ROW(A1:A5))),A1:A5))
which, due to its being non-volatile, is preferable to:
=MAX(SUBTOTAL(9,OFFSET(A1:A5,,,ROW(A1:A5)-MIN(ROW(A1:A5))+1)))
Regards
**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
Related
I have an excel document where I have some amount in number in different cells. For example, I have number in column H,I,J of row 1.
How can I sum H+I and then subtract J from the result of H+I?
Thanks
Hi and welcome to Stack Overflow.
Let's say you have your original value in cell H1, the value to add in cell I1, and the value to subtract from their sum in cell J1.
The formula would be:
=H1+I1-J1
Notes:
Since addition and subtraction are related functions, there is no need to add parentheses to enforce proper order of operations.
Addition operator and subtraction operator signs work, no need for explicit Excel functions. There is no subtract function in Excel (perhaps where your confusion comes from), so if you wanted to use explicit functions you would write
=SUM(H1,I1,J1*-1)
If you're trying to sum over a larger range (entire columns of I and J, for example), let me know and I'll adapt my response.
If you want to add two columns say H1+I1 and subtract J1 from the result(H1+I1) and store the final result into column K1, then first select the K1 column and in the formula section type =H1+I1-J1. In the picture below, I am adding value of A1 and B1. After that subtracting the value of C1 from A1+B1. So, for the cell D1 to show the result of A1+B1-C1, select D1 and write the formula as it is showing in the picture.
Screenshot of the Excel worksheet
I'm working with historic stock prices, and using eight columns I have:
Column A: High
Column B: Low
Column C: Close
Column D: Cx-Cx-4
Column E: Counts the number of consecutive positive numbers in column D
Column F: Counts the number of consecutive negative numbers in column D
Column G: Calculate the difference between the maximum of column A and minimum of column B within a given sequence.
As an example G1 should equal:
=max(A1:A5)-min(B1:B5)
G6 should equal:
=max(A6:A8)-min(B6:B8)
G9 should equal:
=max(A9:A11)-min(B9:B11)
And so on.
I'd like to know if it is possible to automate this calculation, possibly with the use of one or more additional columns.
Welcome to SO!
This may not be the most efficient solution as you need to add two helper columns, but if I understand your requirements correctly, then this idea should work well enough.
First, let's assume that there are 100 rows in your data set. Given that, enter the formula "=A100" in cell G100 and the formula "=B100" in cell H100. This sets up the boundary condition for the formulas in columns G and H. Now, in cell G99, enter this formula:
"=IF(E99="",G100,IF(E100="",A99,MAX(A99,G100)))"
What this formula does is set up a "running maximum" with the following logic:
If the cell in E99 is blank, copy the running maximum from G100, else:
If the cell in E99 is not blank but the cell in E100 is, set up a new running maximum from the cell in A99, else:
Take the maximum of A99 and G100 as the new running maximum.
Similarly, copy the following formula into cell H100:
"=IF(F99="",H100,IF(F100="",B99,MIN(B99,H100)))"
This follows the same logic as the previous formula, but takes the minimum of column B.
Copy or autofill these formulas to the top of the data set. This should now give you running maximum for column A and a running minimum for column B.
The next step is to calculate the difference. I notice from your question, that you only seem to be interested in calculating this difference at the top of each range (G1, G6, G9, etc.), rather than doing it in every row. Given that, we need a slightly more complicated formula.
The boundary condition for this formula is simply "=G1-H1" entered in cell I1. In cell I2, enter this:
"=IF(OR(AND(E2<>"",E1=""),AND(F2<>"",F1="")),G2-H2,"")"
How this works is that it check two conditions that indicate a range boundary:
E1 is blank and E2 is not
or
F1 is blank and F2 is not
If either of these conditions hold, the IF statement is true and "G2-H2" is diplayed, otherwise a blank cell is displayed. Now copy or autofill this formula to the bottom of the data set.
As a final step, you can now hide columns G and H if you don't need them displayed. This should now give you the results I think you're looking for. Please let me know if this doesn't work out for you.
I want to use the command MEDIAN in Excel but I want to make the program so that it takes the value in a column from 1 to a row that depens on a calculation in a different column and row.
For example:
=MEDIAN(G1:G(L1))
where L1 is a calculted value
The calculated value in L1 will vary and therefore this procedure will repeat itself for many couple of times. Therefore, I don't want to write the number (of G) direct into the MEDIAN-function.
Please help me! :)
If I understand it corerctly you want to write a formula that calculate the median for a specific column, but you only want to calculate it from values in the range G1:X, where X is another cell in column G, which you calculate based on some criteria. If so then this would solve it:
=MEDIAN(G1:(INDIRECT(ADDRESS(X;7))))
Where X is your formula that calculates which row, i.e. cell is the last to be included in the column G.
Try this formula.
=MEDIAN($G$1:(INDIRECT(ADDRESS($L$1,COLUMN($G$1)))))
I'm having an issue getting accurate data from the SUMIF function. This appears to be caused by the SKU and Product name being identical however I don't understand why the selected range would be ignored.
SUMIF(G:K,A2,K:K) - Cell D2 is calling for the sum of K yet returning the sum result of K2:M2. All other results in D are correct.
SUMIF(G:K,A2,I:I) - If I change the formula in D to SUM I:I (text not a numeric field) the function returns the sum of K:K
Example file http://tempsend.com/013C2B6378
According to the documentation here the range to be summed starts at the top left of the sum range (K:K in your first example) but its size is given by the size of the criteria range (G:K in your example). So I think that's why you're getting extra columns summed in your result.
If you have multiple criteria involving different columns, you should be able to use SUMIFS.
So let's say your data sit in 8 rows (including the headings).
then you simply need to change your formula to say, look for B2 in column G OR in I, if true, then sum the values in K. Right?
put this formula in B2 and press ctrl+shift+enter to calculate the formula.
=SUM(IF(($G$2:$G$8=B2)+($I$2:$I$8=B2),1,0)*$K$2:$K$8)
then drag and fill down until the last cell.
obviously you need to adjust the ranges in the formula to adapt to your own data.
tell me if you get to the answer via this.
How would you find the biggest difference/change in values of a list of numbers in Excel?
An example of what I'm looking for is 1,3,4,5,9,10,11,13
The value I would look for is 4 as this is the biggest difference (between 5 and 9).
Is there a way to do this with a list in Excel?
A picture is worth a thousand words? :p
EDIT:
Description added:
As shown in the image, put the formula in =A2-A1 in Cell B2 and then drag it down. Once you have your values, use the Max formula to get the maximum value as shown in Cell D5
Add another column to contain the difference. Assuming your values are in column A, then the formula would be "=A2-A1" copied down the list. Few ways after this.
(1) You can eyeball which is largest
(2) you can copy values (make sure is values) to a this column and sort descending
(3) You can build pivot off that this column. and double click the largest to find the detail
If values are in distinct cells (A1:A8):
=MAX($A$2:$A$8-$A$1:$A$7)
seems to work (as an array formula, enter with Ctrl+Shift+Enter).
Put the values in a column.Say, Column A
In cell B1; write a formula. =A2-A1
Copy the same formula to the entire Column B, for every value in column A
Go to the end of column B, and write a new formula, =MAX (B1:B)
Create a new column with the differences:
=A2-A1
And drag down.
Find the max value:
=MAX(B1:B9)
Find the index of the max difference value:
=MATCH(MAX(B1:B9);B1:B9;0)