Excel: Totaling where value is X or Y - excel

I've got an excel spreadsheet where one of the values is X or Y. I want a function to add up the amounts column for all the Xs then the same for all the Ys. So in the example below, the calculation for all Xs would be 1080 and all Ys 1100.
X/Y: Amount
X : 500
Y : 600
X : 580
Y : 500
I'd then like to be able to calculate the mean and median of that figure, so for the mean, take the total of the Xs (1080) and divide by the number of cells with X (2). I don't know how to do this bit either.
Thanks in advance!

So lets assume you have the X and Y in Col A with the values in Col B.
We could use the following formula for the Sum of X:
=SUMIF(A1:A4,"X",B1:B4)
We could use the following formula for the Sum of Y:
=SUMIF(A1:A4,"Y",B1:B4)
As for the Mean we take the above formala and divide by countif like this:
=SUMIF(A1:A4,"X",B1:B4)/COUNTIF(A1:A4,"X")
=SUMIF(A1:A4,"Y",B1:B4)/COUNTIF(A1:A4,"Y")

Related

Multiple MAX in one Excel function

I am trying to find the formula on excel that will solve my problem.
I need to calculate X, which is equivalent to a percentage YĆ·2 (and X has maximum and minimum values which depend on Y)
We have that if Y is less than 500, X represents 25% of Y. In this case, X must take a value between 5 and 125.
If Y is between 500 and 1000, X represents 20% of Y. In this case, X must take a value between 125 and 200.
If Y is greater than 1000, X represents 15% of Y. In this case, X must take a value between 200 and 400.
In order to find the value of X based on the value of Y, I first used this formula (omitting the max and min values)
Y=A2
=IF(A2<500; A2*0,125; IF(A2<=1000; A2*0,1; IF(A2>1000; A2*0,075)))
Now I tried to incorporate in my formula the min and max and that's where I'm stuck
For the first part of the problem (Y<500), I applied this formula:
=MAX((IF(A2<500;A2*0,125));5)
Ideally I would have realized this formula:
=MAX((IF(A2<500; A2*0,125));5) ; MAX((IF(A2<=1000; A2*0,1));125) ; MAX((IF(A2>1000; A2*0,075));200)
But since I can't do it (Excel won't let me), would you have any alternatives to offer me?
Do you want to determine the percentage based on the value but set a minimum?
=IF(A2<500,MAX(A2*0.125,5),IF(A2<=1000,MAX(A2*0.1,125),MAX(A2*0.075,200)))

Calculating contrast values on Excel

I am currently studying experimental designs in statistics and I am calculating values pertaining to 2^3 factorial designs.
The question that I have is particularly with the calculations of the "contrasts".
My goal of this question is to learn how to use the table "Coded Factors" and "Total" in order to get the values "Contrast" using the IF THEN function in Excel.
For example, Contrast A is calculated as : x - y . Where
x = sum of the values in the Total, where the Coded Factor A is + .
And y= sum of the values in the Total, where the Coded Factor A is - .
This would be rather simple, but for the interactions it is a bit more complex.
For example, contrast AC is obtained as : x - y . Where
x = sum of the values in the Total, where the product of Coded Factor A and that of C becomes + .
And y = sum of the values in the Total, where the product of Coded Factor A and that of B becomes - .
I would really appreciate your help.
Edited:
Considering the way how IF statements work, I thought that it might be a good idea to convert the + into 1 and - into -1 to make the calculation straight forward.
Convert all +/- to 1/-1. Use some cells as helper..
Put in these formulas :
J2 --> =LEFT(J1)
K2 --> =MID(J1,2,1)
L2 --> =MID(J1,3,1)
Put
J3 --> =IF(J$2="",1,INDEX($B3:$D3,MATCH(J$2,$B$2:$D$2,0)))
and drag to L10. Then
M3 --> =J3*K3*L3*G3
and drag to M10. Lastly,
M1 --> =SUM(M3:M10)
How to use : Input the Factor comb in cell J1 and the result will be in M1.
Idea : separate the factor text > load the multiplier > multiply Total values with multiplier > get sum.
Hope it helps.

Plotting Number of Events that Occur in an Interval Histogram

In Excel, I have two fields per row, a start date/time and an end date/time. I am looking to plot a histogram that shows how many of the rows' intervals contain the time on the x axis.
For example, some start and end times could be: [1,3], [3,4], [7,9], and [7,8]
And I want an output similar to:
x x x
x x x x x x x
1.2.3.4.5.6.7.8.9
How can this be done?
One way is to split your tuples (say with Text to Columns) into say ColumnsA:B, starting in Row3 (say to Row6) and series filling D1:L9 (or to suit) with D1 = 1 and an integer increase.
Then in D3 copied across to L3 and D3:L3 copied down to Row6:
=IF(AND(D$1>=$A3,D$1<=$B3),"X","")
and in D2 copied across to L2:
=COUNTIF(D3:D6,"X")
Then make a column chart (INSERT > Charts) from D1:L2.
However, I may have misunderstood because there is no particular time significance to the above - the data is just treated like integers.

combining information that meet criteria in one excel cell

I have to combine data that meet certain criteria. the background is: I have a list with parts for a car that has different model series (in this example X,Y,Z). One partnumber can appear multiple times in the list with different model series. I have to know which part is used in which model series.
for example my existing excel table looks like this:
partnumber Model series
100 X
100 Y
100 X
100 Z
200 Z
200 Y
300 X
400 Y
400 Z
afterwards it should look like this:
partnumber Model series usage
100 X X,Y,Z
100 Y X,Y,Z
100 X X,Y,Z
100 Z X,Y,Z
200 Z Y,Z
200 Y Y,Z
300 X X
400 Y X,Y
400 X X,Y
400 Y X,Y
Is there a formula to do that or do I need VBA? It would be great if I could use a formula for that issue.
thank you very much!
You cannot do this with a regular worksheet formula, but if you include the VBA function from here:
http://www.cpearson.com/excel/stringconcatenation.aspx
Then you can use this formula:
=StringConcat(",", IF($A$2:$A$10=A2,$B$2:$B$10,""))
Where "partnumber" is in A2:A10, "model series" is in B2:B10, and the formula is entered in C2 (using Ctrl+Shift+Enter since it's an array formula) and filled down.

How to return fitting equation in excel

In excel, I am doing a simple linear regression of two vector X and Y. When I plot X vs Y and fit with linear equation and the result y = kx + b can be shown in the figure. I need to use k and b for my further calculation. I am wondering if there is any equation that can direct return the value of k and b in excel.
Many thanks in advance for he help!
Assuming x values are in A2:A10 and y in B2:B10, your slope (k) with:
=LINEST(B2:B10,A2:A10)
and the intercept (b) with:
=INTERCEPT(B2:B10,A2:A10)

Resources