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!
 
Oh no, you are correct, I had put it wrong :( The circle should have gone on the center! Let me fix it:

idItemValorColumna3
0094V0XCorrect result should be
0095K13135x181544
0096W8880x
0100T23115XObtained:
0102O24216xFirst Formula167534
0103AQ11435xSecond Formula187314
0105Y12956Third Formula180490
0107Y14010o
0108Y14011
0109B650o
0110B650o
0116P9231o
0117P15000
0118P14059
0119Q1964
0120Q3000x
0121N35825x
0129N8047x
0131C0
0133C0
0134AE30000x
 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Try:

=SUM(IF(D2:D22="o",IF(COUNTIFS(B2:B22,B2:B22,D2:D22,"o")=1,C2:C22,MAXIFS(C2:C22,B2:B22,B2:B22,D2:D22,"o")/COUNTIFS(B2:B22,B2:B22,D2:D22,"o"))))+SUMIF(D2:D22,"x",C2:C22)

This is an array formula. Depending on whether your version of Excel 365 has the latest calculation engine, you might need to confirm the formula by pressing Control+Shift+Enter when you enter the formula in the formula bar.
 
Upvote 0
Solution

Forum statistics

Threads
1,214,614
Messages
6,120,525
Members
448,969
Latest member
mirek8991

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