Using Match to return the highest value for a coincidence

FrankParker

New Member
Joined
Jun 16, 2020
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Hi, this is my first post here!

The reason i suscribed here is because I was looking forward to improve a formula to match my needs. Let me tell you about it a little:

I have this data set:

Post image

When you put an X on column E it sums always the value that is displayed on there, no matter what letter appears on column C. When you put an O, if the letter that appears on column C doesn't have another O then it sums, but if the letter on column A already has another O it doesn't. The letter on column A doesn't always have the same associated value on column B, what I am looking for is that if any letter on column C has two values, when I put a circle in column C, it only sums the highest value, but if the O it's on the lower value only then sums that value.
The idea is that it sums always that I put an X on the far right column, and it only sums once when i put an O.

I used this formula:
SUMIF(E2:E179;"X";$D$2:$D$22)+(SUM(IF(FREQUENCY(IF(ISNUMBER($D$2:$D$22);IF(E2:E22="O"; SI(ISNUMBER(SEARCH("O";E2:E22));MATCH($C$2:$C$22;$C$2:$C$22;0))));ROW($C$2:$C$22)-ROW($C$2)+1);$D$2:$D$22)))

It works mostly as its intended purpose except that if an item in the category has more than one value it sums the first value that appears, but as I told you before, I am trying to make it sum the highest value for each category only when. I could sort the table for the categories, but for later search it would not be optimal.Any idea how I could fix the formula?


Here you have a file to experiment with if you want
Box


Thanks!
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Welcome to the MrExcel forums!

Try:

Book1
ABCDEFGHI
1id
294V0XObtainedX
395K13135OK
496W8880
5100T23115X
6102O24216
7103AQ1143583099
8105Y12956O
9107Y14010O
10108Y14010O
11109B650
12110B650
13116P9231
14117P14059
15118P14059
16119Q1964O
17120Q1964O
18121N35825
19129N8047
20131C0O
21133C0O
22134AE30000X
Sheet2
Cell Formulas
RangeFormula
F7F7=SUMIF(E2:E179,"X",D2:D179)+SUMPRODUCT(--(E2:E179="O"),--(MATCH(D2:D179,D2:D179,0)=ROW(D2:D179)-ROW(D2)+1),MAXIFS(D2:D179,C2:C179,C2:C179,E2:E179,"O"))


See if this does what you want. You'll have to convert it to your local settings (commas --> semicolons, and it appears you started with Spanish terms (IF --> SI).
 
Upvote 0
Oops! :eek:

I referred to the wrong column in the formula, it should be:

Book1
ABCDEFGH
1id
294V0XObtainedX
395K13135OK
496W8880
5100T23115X
6102O24216
7103AQ1143569089
8105Y12956O
9107Y14010O
10108Y14010O
11109B650
12110B650
13116P9231
14117P14059
15118P14059
16119Q1964O
17120Q1964O
18121N35825
19129N8047
20131C0O
21133C0O
22134AE30000X
Sheet2
Cell Formulas
RangeFormula
F7F7=SUMIF(E2:E179,"X",D2:D179)+SUMPRODUCT(--(E2:E179="O"),--(MATCH(C2:C179&"",C2:C179&"",0)=ROW(C2:C179)-ROW(C2)+1),MAXIFS(D2:D179,C2:C179,C2:C179,E2:E179,"O"))
 
Upvote 0
Oh no, just tested it a little bit and found a problem: If you do not count with a circle the first one with the same categorie it doesn't add it to the sum at all somehow :(
 
Upvote 0
I'm not entirely sure what you want, but try this:
Book1
ABCDEFGHI
1id
294V0XObtainedX
395K13135OK69089
496W8880
5100T23115X
6102O24216
7103AQ11435
8105Y12956O
9107Y14010O
10108Y14010O
11109B650
12110B650
13116P9231
14117P14059
15118P14059
16119Q1964O
17120Q1964O
18121N35825
19129N8047
20131C0O
21133C0O
22134AE30000X
23
Sheet2
Cell Formulas
RangeFormula
I3I3=SUMIF(E2:E179,"X",D2:D179)+SUM(IF(COUNTIFS(C2:C179,C2:C179,E2:E179,"O"),MAXIFS(D2:D179,C2:C179,C2:C179)/COUNTIFS(C2:C179,C2:C179)))
Press CTRL+SHIFT+ENTER to enter array formulas surrounded with curly braces.


Note that this one is an array formula.
 
Upvote 0
Oh, sorry, gonna try to be more specific this time: I am trying to make the circles sums only once between the same letter group, if there is more than one value within the group it should sum the higher one only, but if I choose one with a lower value it doesn't have to sum the highest value only should sum the value associated with the ID I have selected. Im gonna leave an image of what I was trying to achieve, maybe its better.

1592350244933.png


But you a really close to get what I was trying to do, really!

Thanks
 
Upvote 0
Oh, sorry, gonna try to be more specific this time: I am trying to make the circles sums only once between the same letter group, if there is more than one value within the group it should sum the higher one only, but if I choose one with a lower value it doesn't have to sum the highest value only should sum the value associated with the ID I have selected. Im gonna leave an image of what I was trying to achieve, maybe its better.

View attachment 16342

But you a really close to get what I was trying to do, really!

Thanks
Oh no, just noticed that if I have three areas for the same letter group I can only sum the higher value or the lower value, but not the one in the middle.
 
Upvote 0
Sorry I haven't replied sooner, but I'm extremely confused as to what you want. In your example from post 7, for the Y group you want 14010 because one of the Y group is marked, and it's the highest in the group. For the P group you want 9231 because it's the only marked one, even though 1500 is higher. Right? But back to the Y group, the only one marked is 12956, so why don't you want that value?
 
Upvote 0

Forum statistics

Threads
1,215,353
Messages
6,124,462
Members
449,163
Latest member
kshealy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top