Find Largest Decimal Value and then display result from a different cell

feni1388

Board Regular
Joined
Feb 19, 2018
Messages
133
Office Version
  1. 2021
Platform
  1. Windows
Hello everyone....

I need to find the highest decimal (column G) among those with the same customer code (if there're more than 1 that have the same customer code in column A. If there's only one like MC05, then no need to return anything) then return it as complete code (column B).
I found a similar problem in another forum and tried using index function but it didn't work out for me.
Does anyone have any suggestion how to fix it?

Thank you in advance.

Book1
ABCDEFGHI
1Customer codeComplete codeTotalVATSumVAT with decimalVAT diff.which code has the highest diff. (didn't work out)The result that I hope to have
2MC01MC010101138,08013,808.00151,88813,808.000.00MC01
3MC02MC020101212,17721,217.00233,39421,217.700.70MC02MC020101
4MC02MC02020130,8753,087.0033,9623,087.500.50MC02
5MC03MC030101215,22021,522.00236,74221,522.000.00MC01
6MC05MC050101361,36536,136.00397,50136,136.500.50MC02
7MC06MC06010189,6008,960.0098,5608,960.000.00MC01
8MC07MC07010137,7503,775.0041,5253,775.000.00MC01
9MC07MC07020181,7408,174.0089,9148,174.000.00MC01
10MC07MC07040123,6002,360.0025,9602,360.000.00MC01
11SISSIS02001339,76033,976.00373,73633,976.000.00MC02
12SISSIS04001512,05051,205.00563,25551,205.000.00MC02
13SISSIS05001156,73015,673.00172,40315,673.000.00MC02
14SISSIS0600113,5001,350.0014,8501,350.000.00MC02
15SISSIS0700157,3605,736.0063,0965,736.000.00MC02
16SISSIS0800115,9101,591.0017,5011,591.000.00MC02
17SISSIS0900114,2001,420.0015,6201,420.000.00MC02
18SISSIS1000136,0403,604.0039,6443,604.000.00MC02
19SISSIS1100124,2002,420.0026,6202,420.000.00MC02
20SISSIS1200124,8602,486.0027,3462,486.000.00MC02
21SISSIS1300118,9001,890.0020,7901,890.000.00MC02
22SISSIS1400120,3202,032.0022,3522,032.000.00MC02
23SISSIS1500113,5001,350.0014,8501,350.000.00MC02
24SISSIS1600119,1851,918.0021,1031,918.500.50MC02SIS16001
Sheet1
Cell Formulas
RangeFormula
D2:D24D2=ROUNDDOWN(C2*10%,0)
E2:E24E2=D2+C2
F2:F24F2=C2*10%
G2:G24G2=F2-TRUNC(D2)
H2:H24H2=INDEX($A$2:$A$24,MATCH(MAXIFS(G:G,A:A,A2),$G$2:$G$24,0))
A2:A10A2=LEFT(B2,4)
A11:A24A11=LEFT(B11,3)
 
Thank you ..... your formula works great too.
Perhaps I have misinterpreted your statement ..
I want to show the code of the one that has the highest total amount (column C)
With the sample data, try changing cell C3 to 12,175. Shouldn't the formula now show the result in row 4 since C4 is now higher than C3?
 
Upvote 0

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
The results of the two formulas are the same.
Book1
ABCDEFGHIJ
1Customer codeComplete codeTotalVATSumVAT with decimalVAT diff.F1F2F3
2MC01MC01010113808013808151888138080   
3MC02MC02010112.175113.1751.21750.2175   
4MC02MC020201308753087339623087.50.5MC020201MC020201MC020201
5MC03MC03010121522021522236742215220   
6MC05MC0501013613653613639750136136.50.5   
7MC06MC0601018960089609856089600   
8MC07MC070101377513775415263775.10.1   
9MC07MC070201817428174899168174.20.2MC070201MC070201MC070201
Sheet1
Cell Formulas
RangeFormula
D2:D9D2=ROUNDDOWN(C2*10%,0)
E2:E9E2=D2+C2
F2:F9F2=C2*10%
G2:G9G2=F2-D2
H2:H9H2=IF(COUNTIF(A$2:A$24,A2)=1,"",LET(m,MAXIFS(G$2:G$24,A$2:A$24,A2),IF(OR(m=0,m<>G2,C2<>MAXIFS(C$2:C$24,A$2:A$24,A2,G$2:G$24,m)),"",B2)))
I2:I9I2=IF(OR(COUNTIF(A$2:A$24,A2)=1,COUNTIFS($A$2:A2,A2,$G$2:G2,G2)>1),"",LET(m,MAXIFS(G$2:G$24,A$2:A$24,A2),IF(OR(m=0,m<>G2),"",B2)))
J2:J9J2=IFS(G2=0,"",COUNTIF(A$2:A$24,A2)=1,"",COUNTIFS($A$2:A2,A2,$G$2:G2,G2)>1,"",G2=MAXIFS(G$2:G$24,A$2:A$24,A2),B2,TRUE,"")
A2:A9A2=LEFT(B2,4)
 
Upvote 0
The results of the two formulas are the same.
Not if you make the change I mentioned.

24 08 21.xlsm
ABCDEFGHI
1Customer codeComplete codeTotalVATSumVAT with decimalVAT diff.ResultResult
2MC01MC010101138,08013808151888138080  
3MC02MC02010112,1751217133921217.50.5 MC020101
4MC02MC02020130,8753087339623087.50.5MC020201 
5MC03MC030101215,22021522236742215220  
6MC05MC050101361,3653613639750136136.50.5  
7MC06MC06010189,60089609856089600  
8MC07MC07010137,75037754152537750  
9MC07MC07020181,74081748991481740  
10MC07MC07040123,60023602596023600  
feni1388 (2)
Cell Formulas
RangeFormula
D2:D10D2=ROUNDDOWN(C2*10%,0)
E2:E10E2=D2+C2
F2:F10F2=C2*10%
G2:G10G2=F2-D2
H2:H10H2=IF(COUNTIF(A$2:A$24,A2)=1,"",LET(m,MAXIFS(G$2:G$24,A$2:A$24,A2),IF(OR(m=0,m<>G2,C2<>MAXIFS(C$2:C$24,A$2:A$24,A2,G$2:G$24,m)),"",B2)))
I2:I10I2=IF(OR(COUNTIF(A$2:A$24,A2)=1,COUNTIFS($A$2:A2,A2,$G$2:G2,G2)>1),"",LET(m,MAXIFS(G$2:G$24,A$2:A$24,A2),IF(OR(m=0,m<>G2),"",B2)))
A2:A10A2=LEFT(B2,4)
 
Upvote 0
Perhaps I have misinterpreted your statement ..

With the sample data, try changing cell C3 to 12,175. Shouldn't the formula now show the result in row 4 since C4 is now higher than C3?
Yes, you're right.
It didn't change when I used Phuoc's formula. It should have changed to C4 instead of C3.
I didn't realise that. Thank you for letting me know.
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,178
Members
452,615
Latest member
bogeys2birdies

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