travelsandbooks
travelsandbooks

Reputation: 333

Excel: column formula with conditions

I want to find the slope and intercept of a column of data, but I want to include an IF function that looks at another column and only counts the data if the condition is met.

Example:

1   54  23
2   34  52
2   25  93
2   13  53
1   88  54

I want to find the SLOPE and INTERCEPT of these variables ONLY WHEN the type is 2.

I know the syntax would be =SLOPE(B:B) but how do I add conditionals?

Upvotes: 0

Views: 197

Answers (1)

asongtoruin
asongtoruin

Reputation: 10359

Assuming your slope calculation done manually would be =SLOPE(B2:B4,C2:C4), to filter to just those where A gives a value of 2 would be =SLOPE(IF(A1:A5=2,B1:B5),IF(A1:A5=2,C1:C5)), entered as an array formula. The IF just filters the ranges you provided when used as an array formula like this.

Upvotes: 1

Related Questions