Formula to change another cell - excel

I'm a novice in excel. I'm using Excel 2010. My spreadsheet looks something like this:
0 A B C D
1 X 10€ X: (sum of all incomes, made by A)
2 Y 20€ Y: (sum of all incomes, made by B)
3 Z 5€ Z: (sum of all incomes, made by C)
4 X 4€
5 Z 6€
I have a list of incomes and outcomes, collected/paid for by 3 different persons. I'd like to format the first column: if the content of the cell is 'X', the income in that row is added to X's sum of all incomes, if it's Y, add to Y's sum, same for Z.
Something like this (for A1):
"if content = X, add B1 to D1; if content = Y, add B1 to D2; if content = Z, add B1 to D3"
How do I write the formula?

Use the =SUMIF() formula.
Before you start, remove the colons from C1, C2 and C3.
In D1 write this formula:
=SUMIF($A$1:$A$5,C1,$B$1:$B$5)
... and copy or drag the formula down to D2 and D3.
Remember the $-signs in the formula to lock the ranges when copying or dragging.

Related

Solving simultaneous equations in excel

I have 4 equations, with 4 unknowns, a,b,c,e
w = c + 0.43*a
x + gb = pc + 2*e
y + 2a + hb = qc + 20.43a + e
z + bi = cr
What would be the best way to solve this in Excel?
I searched and found that LINEST might be a good function to use, but couldn't get it to work
Thanks
First rewrite all you formulas in the form
Ai*(a)+Bi*(b)+Ci*(c)+Ei*(e)=Ki
Then for each equation fill out a row in the matrix
A1 B1 C1 E1 a K1
A2 B2 C2 E2 x b = K2
A3 B3 C3 E3 c K3
A4 B4 C4 E4 e K4
Then use MInverse and MMultiply functions to solve for a,b,c and e
A,B,C,E are the constants multiplying each variable. Set them to 0 when they are not in the formula, and make sure you carry the negative sign.
i is just a way to represent the equation number.
K is the constant in the equation with out a variable attached to it.
So provided I did the formula rearrangement properly, one possible result would be:
Cant take it farther than this as numbers would be needed for g, p, h, q, i, and r (not to mention w, x, y, and z). Though you could set those up in cells so you sheet would automatically update when you entered values.

SUMIFS with multiple criteria and OR logic in multiple columns

I found here an example for doing a sumifs with multiple criteria and OR logic, but I tried with multiple to do it for multiple columns and it is not working.
Here is an example. Base on this dataset:
A1 B1 C1 D1
B X u 11
B X u 22
A X t 22
B X t 22
I'm using the following formula:
=SUM(SUMIFS(D:D,B:B,"X",A:A,{"A","B"},C:C,{"t","u"}))
I get 55 as a result in the formula, but it should be 77 instead
If I change last row of the dataset it calculates correctly like:
A1 B1 C1 D1
B X u 11
B X u 22
A X t 22
A X t 22 --> Column A1 value changed from B to A
Is it possible to have multiple columns with multiple OR values?
Try,
=SUM(SUMIFS(D:D, B:B, "X", A:A, {"A","B"}, C:C, TRANSPOSE({"t","u"})))
By changing the 'direction' in which the second array of criteria is read, you get all possible combinations instead of paired combinations.
I was working on the same lines as #Jeeped but came up with
=SUM(SUMIFS(D:D,B:B,"X",A:A,{"A","B"},C:C,{"t";"u"}))
in order to change the direction of the second array.
Note: I don't know how you would easily extend this to include another set of criteria because you need another 'dimension'. As far as I can see it would have to look like this
=SUM(SUMIFS(D:D,B:B,{"X","X","X","X","Y","Y","Y","Y"},A:A,{"A","A","B","B","A","A","B","B"},C:C,{"t","u","t","u","t","u","t","u"}))

EXCEL counting empty rows

A B C D E F G H
1 Y Y Y X
2 X X
3 Y Y
4 X X
5 Y Y Y X
Count the number of empty rows (from Columns A to E) and put result here. Answer should be 2 from example above.
Hi Folks,
I'm struggling to find the correct Excel formula to count the number of rows with no data from columns A through E, and putting that answer in a cell. These 'empty rows' may have data in later columns (like F, G, H), but I just want to count the rows with no data from columns A to E.
Any help would be appreciated.
Since array formulas tend to confuse people, here's a non-Array formula approach:
Place =IF(COUNTA(A1:E1)=0,1,0) into row 1 of (for example) column I and drag down to row 5. Then place a sum formula below that to get the answer, for example: =SUM(I1:I5)
Try this array formula,
=SUM(IF(ROW(1:5), IF(A1:A5&B1:B5&C1:C5&D1:D5&E1:E5="", 1)))
Remember to finalize with ctrl+shift+enter, not just enter.
You could also use a variation on the standard formula for getting row sums of a 2d array
=SUM(N(MMULT(N(A1:E5=""),TRANSPOSE(COLUMN(A1:E5)^0))=COLUMNS(A1:E5)))
or
=SUM(N(MMULT(N(A1:E5="Y"),TRANSPOSE(COLUMN(A1:E5)^0))=0))
Again they are array formulas and have to be entered with CtrlShiftEnter

How to use the Polynomial Trendline Formula

So the blue line graph has values from column CM (x values are in column CF, sorry for the confusing presentation). I want to recreate the polynomial trendline that I had excel generate for it, which is what I'm trying to do in column CH, as you can see from the formula bar.
Excel gives me the formula y = -0,0006x^2 + 0,013x + 0,1878 (shown on the chart) which I then have entered into the values in column CH.
The result is unfortunately not even close (displayed as the orange line graph). Is there any person here sharp enough on maths to tell me what I'm doing wrong?
This is the formula to obtain 2nd Order Polynomial Trendline:
y = (c2 * x^2) + (c1 * x) + b
c2: =INDEX(LINEST(y,x^{1,2}),1)
c1: =INDEX(LINEST(y,x^{1,2}),1,2)
b: =INDEX(LINEST(y,x^{1,2}),1,3)
So now, just examined your formula, you have incorrect parameters (b, c1 and c2) used so the result is different.
Here are the formulas I used to obtain these three parameters:
c2: =INDEX(LINEST($CM$1234:$CM$1262,$CF$1234:$CF$1262^{1,2}),1)
c1: =INDEX(LINEST($CM$1234:$CM$1262,$CF$1234:$CF$1262^{1,2}),1,2)
b: =INDEX(LINEST($CM$1234:$CM$1262,$CF$1234:$CF$1262^{1,2}),1,3)
Then I got:
c2 (cell CG1227) = -0.05675
c1 (cell CG1228) = -0.04025
b (cell CG1229) = 0.25509
Now, from cell CH1234, this formula is used:
=($CG$1227*CF1234^2)+($CG$1228*CF1234)+$CG$1229
I have the outcome matched with the Polynomial Trendline. Try and see if this works for you.

Return value of last populated cell in variable range

Into column D, I'd like to copy the value from the last cell with data in columns E up until the column with the header "DETAIL". There might be anywhere from 2 to 15 columns from E until the column with that header, so that's where I'm stuck. So to be clear, an example:
A B C D E F G H DETAIL
1 x x x a b c d x
2 x x x x
3 x x x c b a x
3 x x x d c x
Should fill column D like so:
A B C D E F G H DETAIL
1 x x x d a b c d x
2 x x x x
3 x x x a c b a x
3 x x x c d c x
I don't mind handling this with a formula (which I couldn't come up with) or programmatically.
Create a dynamic named range by pressing CtrlF3 to bring up the Name Manager, click New, name the range something (I chose MyRange) and then use this formula to define it (Note you may need to change the Sheet name):
=Sheet1!E2:INDEX(Sheet1!2:2,MATCH("Detail",Sheet1!$1:$1,0)-1)
Then, in cell D2 and copied down, use this formula (I did not use IFERROR so that it would be backwards compatible):
=IF(COUNTA(MyRange),INDEX(MyRange,MATCH(REPT("z",255),MyRange)),"")
Here are the results (highlighted) using your provided sample data:
Please try:
=IFERROR(INDEX(F2:T2,,MATCH("zzzzzz",F2:T2)),"")
in D2 and copied down to suit.
Try using LOOKUP:
=IFERROR(LOOKUP(9^99,SEARCH("*",E1:H1),E1:H1),"")
SEARCH("*",E1:H1) returns a number when it matches any character and an error when the cell is blank. LOOKUP then returns the contents of the cells of the last number smaller than 9^99 in the array generated by SEARCH.
For example, in the first row, SEARCH("*",E1:H1) returns {1,1,1,1} so that LOOKUP returns the last 1, being d.
In the third row, SEARCH("*",E3:H3) returns {1, 1, 1, #VALUE!} and LOOKUP returns the last 1, which is a here.
This formula will work with numbers and text alike. The downside is that it is considered slower than INDEX/MATCH. On the other hand, you can modify the INDEX/MATCH to work with numbers, or modify it to work for both but becomes an array formula:
=IFERROR(INDEX(E1:H1,,MATCH(1,SEARCH("*",E1:H1))),"")
[Works with Ctrl+Shift+Enter, otherwise returns an empty cell with Enter alone]

Resources