Conditional Formatting with Duplicate Rows to Identify Most Recent Value

rac241985

New Member
Joined
Jan 30, 2017
Messages
27
I have multiple rows with identical values in 3 columns and the 4th column has a unique value based on the date when it is sold. Can someone please help me in creating a 5th column which will show me based on conditional formatting value which was sold earlier and which was sold more recently? If it is sold on a previous date then I want it to show the output as “Old” else the output should be “new”. Additionally, if there are no duplicate rows, then the desired output will always be “New”.

Product
Country
Units Sold
Date (mm/dd/yy)
Desired Output
Apple
Taiwan
100
1/12/15
Old
Apple
Taiwan
100
2/25/15
New
Apple
China
50
1/27/16
New
Samsung
Taiwan
100
2/25/15
New
Samsung
Taiwan
100
1/25/14
Old

<tbody>
</tbody>

Any help will be appreciated!

Thanks!
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Hi!

Try the formula below in E2 and copy down

=IFERROR(IF(LARGE(IF(MMULT(--($A$2:$C$6=A2:C2),{1;1;1})=3,$D$2:$D$6),2)=D2,"Old","New"),"New")

Markmzz
 
Last edited:
Upvote 0
If you have more then two values, try this:

=IF(LARGE(IF(MMULT(--($A$2:$C$7=A2:C2),{1;1;1})=3,$D$2:$D$7),1)<>D2,"Old","New")

Or

=IF(LARGE(IF(MMULT(--($A$2:$C$7=A2:C2),{1;1;1})=3,$D$2:$D$7),1)=D2,"New","Old")

Markmzz
 
Last edited:
Upvote 0
Thanks a lot Markmzz!! It works like charm. However, since I am relatively new, can you explain how this code works? It will be really beneficial to understand rather than just copy paste :). Once again! Thanks a ton and appreciate your help.
 
Upvote 0
Thanks a lot Markmzz!! It works like charm. However, since I am relatively new, can you explain how this code works? It will be really beneficial to understand rather than just copy paste :). Once again! Thanks a ton and appreciate your help.

Lets look at the row 2 and the formula there - step-by-step:


ABCDEFGHIJKLM
1ProductCountryUnits SoldDateOutputLets look at row 2Formula=IF(LARGE(IF(MMULT(--($A$2:$C$7=A2:C2),{1;1;1})=3,$D$2:$D$7),1)=D2,"New","Old")
2AppleTaiwan10012/01/2015OldStep-By-Step
3AppleTaiwan10025/02/2015New{1;1;1}
4AppleChina5027/01/2016New1
5SamsungTaiwan10025/02/2015New1
6SamsungTaiwan10025/01/2014Old1
7--($A$2:$C$7=A2:C2)1113MMULT(--($A$2:$C$7=A2:C2),{1;1;1})
81113
91001
100112
110112
12
13TRUEMMULT(--($A$2:$C$7=A2:C2),{1;1;1})=3
14TRUE
15FALSE
16FALSE
17FALSE
18
1912/01/2015IF(MMULT(--($A$2:$C$7=A2:C2),{1;1;1})=3,$D$2:$D$7)
2025/02/2015
21FALSE
22FALSE
23FALSE
24
2525/02/2015LARGE(IF(MMULT(--($A$2:$C$7=A2:C2),{1;1;1})=3,$D$2:$D$7),1)
26
27FALSELARGE(IF(MMULT(--($A$2:$C$7=A2:C2),{1;1;1})=3,$D$2:$D$7),1)=D2
28
29Old=IF(LARGE(IF(MMULT(--($A$2:$C$7=A2:C2),{1;1;1})=3,$D$2:$D$7),1)=D2,"New","Old")
30
**************************************************************************************

<tbody>
</tbody>

I hope that the table above helps.

Markmzz
 
Upvote 0
HI Mark,


Thanks for the breakdown! This is helpful. However, can you please also explain me what "--" stands for in the MMULT function you have used ?

Regards,
 
Upvote 0
HI Mark,


Thanks for the breakdown! This is helpful. However, can you please also explain me what "--" stands for in the MMULT function you have used ?

Regards,

Yes. The -- is the same -1*-1 that is the same 1. So --=-1*-1=1. So you can use in the formula this too: 1*($A$2:$C$7=A2:C2) or -1*-1*($A$2:$C$7=A2:C2)<strike></strike>

I hope that helps.

Markmzz
 
Upvote 0
HI Mark,

Thanks for the breakdown! This is helpful. However, can you please also explain me what "--" stands for in the MMULT function you have used ?

Regards,

Yes. The -- is the same -1*-1 that is the same 1. So --=-1*-1=1. So you can use in the formula this too: 1*($A$2:$C$7=A2:C2) or -1*-1*($A$2:$C$7=A2:C2)<strike></strike>

I hope that helps.

Markmzz

One more thing: The -- will transform TRUE into 1 and FALSE into 0. In the link below you have more information about TRUE and FALSE in Excel.

https://www.deskbright.com/excel/true-false-excel/

Here is more one step-by-step table.

ABCDEFGHIJK
1ProductCountryUnits SoldDateOutput($A$2:$C$7=A2:C2)TRUETRUETRUE
2AppleTaiwan10012/01/2015OldTRUETRUETRUE
3AppleTaiwan10025/02/2015NewTRUEFALSEFALSE
4AppleChina5027/01/2016NewFALSETRUETRUE
5SamsungTaiwan10025/02/2015NewFALSETRUETRUE
6SamsungTaiwan10025/01/2014Old
7--($A$2:$C$7=A2:C2)111
8-1*-1*($A$2:$C$7=A2:C2)111
91*($A$2:$C$7=A2:C2)100
10011
11011
12
**********************************************************

<tbody>
</tbody>

Markmzz
 
Upvote 0

Forum statistics

Threads
1,214,551
Messages
6,120,156
Members
448,948
Latest member
spamiki

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