Compute MIN and MAX in table column according to some condition - excel

I have a datasheet with 5 columns, 3 for input values and 2 for output values
A) Date
B) Number
C) Number
D) Number
E) Number
Column B has set of dates with possible repetitions.
Column C has the max value (and Column D has the min value) for an observation in a given date, which is the one in column B. Some values may be empty.
Given that in B I can have repetitions, I need to compute the following: for any given date in B, compute the max (or min) of all observations for that date and store it in column D (or E).
I cannot use MACROs.
Example.
Suppose D1 and D2 are valid dates
Input:
A B C
D1 9 3
D1 8 2
D2 7 5
D2 3
Output:
A B C D E
D1 9 3 9 2 (the max for all dates of type D1 is 9, while the min is 2
D1 8 2 9 2
D2 7 5 7 3 (the max for all dates of type D2 is 7, while the min is 3
D2 3 7 3
How can I do that?

=MIN(IF(A:A=A4,C:C)) works for me, if you add Control+Shift+Enter when you're in the cell.
It looks like excel adds {} around the whole formula when you do.

Related

Count unique values in excel based on multiple criteria

I've got a spreadsheet with 3 columns and want a formula to count the unique values in column A based on 3 criteria against B and C.
Below is an example of the data and desired output. E2:H2 is where the formula should go. The data contains blank values in column C. Column B is the result of a vlookup.
A B C D E F G H
1 Email List Date 1/1/19 1/2/19 1/3/19 1/4/19
2 1#1.com X 1/1/19 2 1 1 0
3 2#2.com Y 6/3/19
4 3#3.com Z 2/2/18
5 1#1.com X 9/1/19
6 4#4.com X 5/2/19
7 1#1.com X
8 5#5.com X 4/1/19
9 4#4.com X 3/2/19
10 5#5.com X 4/3/19
I want to find the number of unique values in column A where column B == X and column C falls within a particular month (provided by E1:H1).
I'd like to avoid using multiple pivot tables for each date range if possible.
I've tried two formulas which don't work.
{=SUM(IF((B2:B10="X")*(C2:C10>=E$1)*(C2:C10<F$1), 1 / COUNTIFS(B2:B10, "X", C2:C10, ">="&E$1, C2:C10, "<"&F$1, A2:A10, A3:A10)), 0)}
=SUMPRODUCT(((B2:B10="X")*(C2:C10>=E$1)*(C2:C10<F$1)) / (COUNTIFS(A:A, A2:A10, B2:B10, "X", C2:C10, ">="&E$1, C2:C10, "<"&F$1)))
I've seen similar questions in Stack Overflow but none worked for me.
Any help appreciated.
You could implement some BOOLEAN logic and check if MONTH and YEAR in C:C are the same as the lookup month and multiply that against your "x" criteria in column B:B:
Formula in E2:
=SUM(--(FREQUENCY(IF((MONTH($C$2:$C$10)=MONTH(E1))*(YEAR($C$2:$C$10)=YEAR(E1))*($B$2:$B$10="X"),MATCH($A$2:$A$10,$A$2:$A$10,0)),ROW($A$2:$A$10)-ROW($A$2)+1)>0))
Note: It's an array formula and needs to be confirmed through CtrlShiftEnter
Drag right...

Deducting numbers based on value in a different column

I have a C column with several rows containing numbers. I have another E Column with rankings.
I would like a formula that will automatically change the number in a 3rd column G based on the ranking in E column
So,
If the ranking is 2 in E the number in G is number in column C
minus 1
If the ranking is 1 the number in E the number in G is
number in column C minus 2
Any other ranking the number remains the
same.
Example -
C E G
19 2 18
12 1 10
15 3 15
Put below formula in G column -
=IF(E1=1,C1-2,IF(E1=2,C1-1,C1))
Above formula is for row 1. Adjust row value according to your need.
Explanation -
Check if E column contains 1, then subtract 2 from C column
Else, check if E column contains 2, then subtract 1 from C
column
Else, G column is same as C column

Increment value in Excel column depending on existing values in other column

I have 4 columns in Excel: A, B, C, and D. I want two of the columns (C & D) to auto-populate based on the input in the other two columns (A & B). The first column that auto-populates (C) should start at 1 and increment each time a new value is added in the same row of column B. Column D should also start at 1 and increment each time a new value is added in the same row of column B, however, if column A has the same value as the previous row (i.e., a date) then it should not increment but instead be the same value as column D in the previous row. Additionally, if a value in column B is repeated, but with a different value (i.e., a date) in column A, then it's corresponding value in column C should be the same as before, but the value in column D should still increment because the value in column A is new.
To visualize:
A B C D
Jan. 5 red 1 1
Jan. 5 gre 2 1
Jan. 6 pin 3 2
Jan. 6 pur 4 2
Jan. 7 bla 5 3
Jan. 7 blu 6 3
Jan. 8 red 1 4
Jan. 8 gre 2 4
Jan. 9 yel 7 5
Jan. 9 ora 8 5
I hope this makes sense. Any help would be greatly appreciated!
Assuming "A" is in cell A1, hardcode 1 in C2 and D2 then in C3 and downwards:
=iferror(index($C$2:$C2,match(B3,$B$2:$B2,0)),max($C$2:$C2)+1)
and in D3 and downwards:
=if(A3="","",if(A3=A2,D2,max($D$2:D2)+1))

Contruct cumulative sum for duplicates

I am looking for formula in Excel to construct cumulative sum for the duplicates.
Item Value Cumulative sum
-----------------------------
A 3 3
A1 4 4
A1 7 11
A1 5 16
B1 20 20
B1 4 24
C 6 6
D 10 10
E 8 8
E 7 15
The table given shows the cumulative for the duplicates in Column 1(Item).
I need excel formula to construct this for my calculations.
Break problems like these down step-by-step.
(Assume your data are in A1:C11 (col C is empty except for the header).)
To calculate a cumulative sum, you just add the current value in col B to the previous value in col C. This is simply =C1+B2 in C2, =C2+B3 in C3, etc.
To evaluate whether you are in the same group of Item, you can simply test whether A2=A1, A3=A2, etc.
To reset your cumulative sum when the group changes, you can use an IF() function. In (2), you have a logical condition. In (1), you have an operation to perform if the condition is true. If the condition is not true, you want to reset the cumulative sum, which is simply the value of col B in the current row.
So to put it together (in C2):
=IF(A2=A1, C1+B2, B2)
Then fill down.

Add values in excel column for distinct values in another column

I have the following layout of column A and B and I need a formula to calculate values in column C:
A B C
1 10 70
1 20
1 10
1 30
2 10 30
2 15
2 5
3 20 25
3 2
3 3
Any ideas or functions which can do this? Basically Sum column B for unique values of column A
In C1 enter:
=SUMIF(A:A,A1,B:B)
and in C2 enter:
=IF(A1=A2,"",SUMIF(A:A,A2,B:B))
and copy down:

Resources