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)
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Are the yellow cells supposed to be telling us something?

There are 3 rows with Customer code MC07. Why is there nothing in column I for them?

In column G, wouldn't =F2-D2 do the same us using TRUNC()?

See if this helps anyway

24 08 21.xlsm
ABGI
1Customer codeComplete codeVAT diff.
2MC01MC0101010.00 
3MC02MC0201010.70MC020101
4MC02MC0202010.50 
5MC03MC0301010.00 
6MC05MC0501010.50 
7MC06MC0601010.00 
8MC07MC0701010.00 
9MC07MC0702010.00 
10MC07MC0704010.00 
11SISSIS020010.00 
12SISSIS040010.00 
13SISSIS050010.00 
14SISSIS060010.00 
15SISSIS070010.00 
16SISSIS080010.00 
17SISSIS090010.00 
18SISSIS100010.00 
19SISSIS110010.00 
20SISSIS120010.00 
21SISSIS130010.00 
22SISSIS140010.00 
23SISSIS150010.00 
24SISSIS160010.50SIS16001
feni1388
Cell Formulas
RangeFormula
I2:I24I2=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),"",B2)))
 
Upvote 0
Are the yellow cells supposed to be telling us something?

There are 3 rows with Customer code MC07. Why is there nothing in column I for them?

In column G, wouldn't =F2-D2 do the same us using TRUNC()?

See if this helps anyway

24 08 21.xlsm
ABGI
1Customer codeComplete codeVAT diff.
2MC01MC0101010.00 
3MC02MC0201010.70MC020101
4MC02MC0202010.50 
5MC03MC0301010.00 
6MC05MC0501010.50 
7MC06MC0601010.00 
8MC07MC0701010.00 
9MC07MC0702010.00 
10MC07MC0704010.00 
11SISSIS020010.00 
12SISSIS040010.00 
13SISSIS050010.00 
14SISSIS060010.00 
15SISSIS070010.00 
16SISSIS080010.00 
17SISSIS090010.00 
18SISSIS100010.00 
19SISSIS110010.00 
20SISSIS120010.00 
21SISSIS130010.00 
22SISSIS140010.00 
23SISSIS150010.00 
24SISSIS160010.50SIS16001
feni1388
Cell Formulas
RangeFormula
I2:I24I2=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),"",B2)))

Are the yellow cells supposed to be telling us something?
--> No, I just want to show where the difference is

There are 3 rows with Customer code MC07. Why is there nothing in column I for them?
--> Because the VAT difference in column G is 0

In column G, wouldn't =F2-D2 do the same us using TRUNC()?
--> Yes, you're right. I don't know why I used that. Thank you.

Thank you so much.... your formula works great.
I'll try it again on different cases.
 
Upvote 0
You're welcome. Thanks for the follow-up & clarifications. :)
 
Upvote 0
You're welcome. Thanks for the follow-up & clarifications. :)
Dear Peter,

Please help again.
In the first table, the VAT difference is obvious, which is 0.7 and 0.5.
But in case it has the same 0.5 and 0.5, I want to show the code of the one that has the highest total amount (column C), in this case MC020101.

I tried to modify it myself, but it didn't work.

Book1
ABCDEFGHI
1Customer codeComplete codeTotalVATSumVAT with decimalVAT diff.The current resultThe result that I hope to have
2MC01MC010101138,08013,808.00151,88813,808.000.00 
3MC02MC020101212,17521,217.00233,39221,217.500.50MC020101MC020101
4MC02MC02020130,8753,087.0033,9623,087.500.50MC020201
5MC03MC030101215,22021,522.00236,74221,522.000.00 
6MC05MC050101361,36536,136.00397,50136,136.500.50 
7MC06MC06010189,6008,960.0098,5608,960.000.00 
8MC07MC07010137,7503,775.0041,5253,775.000.00 
9MC07MC07020181,7408,174.0089,9148,174.000.00 
10MC07MC07040123,6002,360.0025,9602,360.000.00 
Sheet1
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),"",B2)))
A2:A10A2=LEFT(B2,4)
 
Upvote 0
Try change to:

Excel Formula:
=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)))
 
Upvote 0
This is my reading of it.

24 08 21.xlsm
ABCGH
1Customer codeComplete codeTotalVAT diff.Result
2MC01MC010101138,0800 
3MC02MC020101212,1750.5MC020101
4MC02MC02020130,8750.5 
5MC03MC030101215,2200 
6MC05MC050101361,3650.5 
7MC06MC06010189,6000 
8MC07MC07010137,7500 
9MC07MC07020181,7400 
10MC07MC07040123,6000 
feni1388 (2)
Cell Formulas
RangeFormula
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)))
A2:A10A2=LEFT(B2,4)
 
Upvote 0
Solution
This is my reading of it.

24 08 21.xlsm
ABCGH
1Customer codeComplete codeTotalVAT diff.Result
2MC01MC010101138,0800 
3MC02MC020101212,1750.5MC020101
4MC02MC02020130,8750.5 
5MC03MC030101215,2200 
6MC05MC050101361,3650.5 
7MC06MC06010189,6000 
8MC07MC07010137,7500 
9MC07MC07020181,7400 
10MC07MC07040123,6000 
feni1388 (2)
Cell Formulas
RangeFormula
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)))
A2:A10A2=LEFT(B2,4)
Thank you so much.... it works perfectly.
 
Upvote 0
Try change to:

Excel Formula:
=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)))

Thank you ..... your formula works great too.
 
Upvote 0

Forum statistics

Threads
1,224,875
Messages
6,181,513
Members
453,050
Latest member
Obil

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