I have a dataset that looks like below. Column E would be my formula column. I would like Column E to read "Max" for the row where the ID contains the max probability for that state. If two IDs for the same State have the same probability, as in Maryland, I want "Max" to show for the ID with the nearest Date. If two IDs match on both Probability and Date, then I want "Max" to appear for only one ID within each group of States.
Column A Column B Column C Column D Column E
State Probability Date ID Formula Field
California 10% 12/31/2016 123
California 20% 1/7/2017 129
California 23% 1/14/2017 135 Max
Colorado 26% 1/21/2017 141
Colorado 38% 12/31/2016 147 Max
Illinois 44% 1/14/2017 153 Max
Illinois 44% 1/14/2017 159
Illinois 20% 1/21/2017 165
Illinois 35% 1/28/2017 171
Maryland 41% 2/4/2017 177
Maryland 41% 12/31/2016 183 Max
Maryland 35% 1/7/2017 189
Michigan 20% 1/14/2017 195
Michigan 35% 1/21/2017 201
Michigan 38% 1/28/2017 207 Max
West Virginia 41% 2/4/2017 213
West Virginia 44% 2/11/2017 219 Max
Here is the new formula:
This is an array formula. Being an array it must be confirmed with Ctrl-Shift-Enter. If done properly excel will put
{}
around the formula.As per your comments the following formulas will work when IDs are text.
To get the first row where the criteria match, when there are duplicates:
To put "Max" in both when there is a tie:
Using the COUNTIFS approach used in my previous answer,
This might help but its a little cumbersome. The return of the function apparently cannot be blank so it will have a 0 in all the other rows. But if you use this function your range must be selected the same for every group. ** Also the function would have to be in the column right next to it or you would have to edit the function in the offset by however many columns you want to look at.
Link to Excel sheet screenshot