unique record list with formula condition to month

faizee

Board Regular
Joined
Jan 28, 2009
Messages
214
Office Version
  1. 2016
Platform
  1. Windows
I NEED THE UNIQUE RECORD LIST WITH FORMULA, OF EACH SELECTED MONTH

[TABLE="width: 517"]
<TBODY>[TR]
[TD]NAMES</SPAN>[/TD]
[TD]DATE</SPAN>[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]JOHN</SPAN>[/TD]
[TD="align: right"]5-Jan-12</SPAN>[/TD]
[TD][/TD]
[TD]UNIQUE RECORD OF MONTH</SPAN>[/TD]
[TD="align: right"]Feb-12</SPAN>[/TD]
[/TR]
[TR]
[TD]FAIZAN</SPAN>[/TD]
[TD="align: right"]6-Jan-12</SPAN>[/TD]
[TD][/TD]
[TD] [/TD]
[TD][/TD]
[/TR]
[TR]
[TD]ZEESHAN</SPAN>[/TD]
[TD="align: right"]5-Jan-12</SPAN>[/TD]
[TD][/TD]
[TD] [/TD]
[TD][/TD]
[/TR]
[TR]
[TD]FAIZAN</SPAN>[/TD]
[TD="align: right"]10-Jan-12</SPAN>[/TD]
[TD][/TD]
[TD] [/TD]
[TD][/TD]
[/TR]
[TR]
[TD]ZEESHAN</SPAN>[/TD]
[TD="align: right"]15-Jan-12</SPAN>[/TD]
[TD][/TD]
[TD] [/TD]
[TD][/TD]
[/TR]
[TR]
[TD]FAIZAN</SPAN>[/TD]
[TD="align: right"]25-Jan-12</SPAN>[/TD]
[TD][/TD]
[TD] [/TD]
[TD][/TD]
[/TR]
[TR]
[TD]JOHN</SPAN>[/TD]
[TD="align: right"]5-Feb-12</SPAN>[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]SALMAN</SPAN>[/TD]
[TD="align: right"]15-Feb-12</SPAN>[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]FAIZAN</SPAN>[/TD]
[TD="align: right"]20-Feb-12</SPAN>[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]FAIZAN</SPAN>[/TD]
[TD="align: right"]21-Feb-12</SPAN>[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]FAIZAN</SPAN>[/TD]
[TD="align: right"]25-Feb-12</SPAN>[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]ZEESHAN</SPAN>[/TD]
[TD="align: right"]28-Feb-12</SPAN>[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]ZEESHAN</SPAN>[/TD]
[TD="align: right"]15-Feb-12</SPAN>[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]SADFER</SPAN>[/TD]
[TD="align: right"]5-Mar-12</SPAN>[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 3"]THE RESULT OF FEB-12, SHOULD BE</SPAN>[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]UNIQUE LIST</SPAN>[/TD]
[TD="align: right"]12-Feb</SPAN>[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]JOHN</SPAN>[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]SALMAN</SPAN>[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]FAIZAN</SPAN>[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]ZEESHAN</SPAN>[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</TBODY><COLGROUP><COL><COL><COL><COL><COL></COLGROUP>[/TABLE]
 

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.
This is two step process:
If your data are in range A1:B15
In D1: 1/2/2012
In E1:
=SUMPRODUCT(--(MONTH($B$2:$B$15)=MONTH(D1)))
In E2:
=IF(ROWS($C$2:$C2)<=$E$1,INDEX($A$2:$A$200,SMALL(IF(MONTH($B$2:$B$200)=MONTH($D$1),ROW($C$2:$C$200)-ROW($C$2)+1),ROWS($C$2:$C2))),"")
confirm Control+Shift+Enter

In G1="unique"
In G2:
=IFERROR(INDEX($E$2:$E$15,MATCH(0,COUNTIFS($G$1:G1,$E$2:$E$15),0)),"")
confirm Control+Shift+Enter

This will work in Excel 07/10.
For Excel 03:
=IF(ISNA(MATCH(0,COUNTIFS($G$1:G1,$E$2:$E$15),0)),"",INDEX($E$2:$E$15,MATCH(0,COUNTIFS($G$1:G1,$E$2:$E$15),0)))
 
Upvote 0
I NEED THE UNIQUE RECORD LIST WITH FORMULA, OF EACH SELECTED MONTH
...

This does also carry out the year test... It's pretty fast and extendible.
[TABLE="width: 564"]
<colgroup><col style="width: 71pt; mso-width-source: userset; mso-width-alt: 3384;" width="95"> <col style="width: 90pt; mso-width-source: userset; mso-width-alt: 4266;" width="120"> <col style="width: 48pt;" width="64"> <col style="width: 227pt; mso-width-source: userset; mso-width-alt: 10752;" width="302"> <col style="width: 128pt; mso-width-source: userset; mso-width-alt: 6058;" width="170"> <tbody>[TR]
[TD="class: xl63, width: 95, bgcolor: white"]NAMES[/TD]
[TD="class: xl63, width: 120, bgcolor: white"]DATE[/TD]
[TD="class: xl64, width: 64, bgcolor: white"] [/TD]
[TD="class: xl64, width: 302, bgcolor: white"]4[/TD]
[TD="class: xl64, width: 170, bgcolor: white"] [/TD]
[/TR]
[TR]
[TD="class: xl64, width: 95, bgcolor: white"]JOHN[/TD]
[TD="class: xl65, width: 120, bgcolor: white"]5-Jan-12[/TD]
[TD="class: xl64, width: 64, bgcolor: white"] [/TD]
[TD="class: xl64, width: 302, bgcolor: white"]UNIQUE RECORD OF MONTH[/TD]
[TD="class: xl65, width: 170, bgcolor: white"]1-Feb-12[/TD]
[/TR]
[TR]
[TD="class: xl64, width: 95, bgcolor: white"]FAIZAN[/TD]
[TD="class: xl65, width: 120, bgcolor: white"]6-Jan-12[/TD]
[TD="class: xl64, width: 64, bgcolor: white"] [/TD]
[TD="class: xl64, width: 302, bgcolor: white"]JOHN[/TD]
[TD="class: xl64, width: 170, bgcolor: white"] [/TD]
[/TR]
[TR]
[TD="class: xl64, width: 95, bgcolor: white"]ZEESHAN[/TD]
[TD="class: xl65, width: 120, bgcolor: white"]5-Jan-12[/TD]
[TD="class: xl64, width: 64, bgcolor: white"] [/TD]
[TD="class: xl64, width: 302, bgcolor: white"]FAIZAN[/TD]
[TD="class: xl64, width: 170, bgcolor: white"] [/TD]
[/TR]
[TR]
[TD="class: xl64, width: 95, bgcolor: white"]FAIZAN[/TD]
[TD="class: xl65, width: 120, bgcolor: white"]10-Jan-12[/TD]
[TD="class: xl64, width: 64, bgcolor: white"] [/TD]
[TD="class: xl64, width: 302, bgcolor: white"]ZEESHAN[/TD]
[TD="class: xl64, width: 170, bgcolor: white"] [/TD]
[/TR]
[TR]
[TD="class: xl64, width: 95, bgcolor: white"]ZEESHAN[/TD]
[TD="class: xl65, width: 120, bgcolor: white"]15-Jan-12[/TD]
[TD="class: xl64, width: 64, bgcolor: white"] [/TD]
[TD="class: xl64, width: 302, bgcolor: white"]SALMAN[/TD]
[TD="class: xl64, width: 170, bgcolor: white"] [/TD]
[/TR]
[TR]
[TD="class: xl64, width: 95, bgcolor: white"]FAIZAN[/TD]
[TD="class: xl65, width: 120, bgcolor: white"]25-Jan-12[/TD]
[TD="class: xl64, width: 64, bgcolor: white"] [/TD]
[TD="class: xl64, width: 302, bgcolor: white"] [/TD]
[TD="class: xl64, width: 170, bgcolor: white"] [/TD]
[/TR]
[TR]
[TD="class: xl64, width: 95, bgcolor: white"]JOHN[/TD]
[TD="class: xl65, width: 120, bgcolor: white"]5-Feb-12[/TD]
[TD="class: xl64, width: 64, bgcolor: white"] [/TD]
[TD="class: xl64, width: 302, bgcolor: white"] [/TD]
[TD="class: xl64, width: 170, bgcolor: white"] [/TD]
[/TR]
[TR]
[TD="class: xl64, width: 95, bgcolor: white"]SALMAN[/TD]
[TD="class: xl65, width: 120, bgcolor: white"]15-Feb-12[/TD]
[TD="class: xl64, width: 64, bgcolor: white"] [/TD]
[TD="class: xl64, width: 302, bgcolor: white"] [/TD]
[TD="class: xl64, width: 170, bgcolor: white"] [/TD]
[/TR]
[TR]
[TD="class: xl64, width: 95, bgcolor: white"]FAIZAN[/TD]
[TD="class: xl65, width: 120, bgcolor: white"]20-Feb-12[/TD]
[TD="class: xl64, width: 64, bgcolor: white"] [/TD]
[TD="class: xl64, width: 302, bgcolor: white"] [/TD]
[TD="class: xl64, width: 170, bgcolor: white"] [/TD]
[/TR]
[TR]
[TD="class: xl64, width: 95, bgcolor: white"]FAIZAN[/TD]
[TD="class: xl65, width: 120, bgcolor: white"]21-Feb-12[/TD]
[TD="class: xl64, width: 64, bgcolor: white"] [/TD]
[TD="class: xl64, width: 302, bgcolor: white"] [/TD]
[TD="class: xl64, width: 170, bgcolor: white"] [/TD]
[/TR]
[TR]
[TD="class: xl64, width: 95, bgcolor: white"]FAIZAN[/TD]
[TD="class: xl65, width: 120, bgcolor: white"]25-Feb-12[/TD]
[TD="class: xl64, width: 64, bgcolor: white"] [/TD]
[TD="class: xl64, width: 302, bgcolor: white"] [/TD]
[TD="class: xl64, width: 170, bgcolor: white"] [/TD]
[/TR]
[TR]
[TD="class: xl64, width: 95, bgcolor: white"]ZEESHAN[/TD]
[TD="class: xl65, width: 120, bgcolor: white"]28-Feb-12[/TD]
[TD="class: xl64, width: 64, bgcolor: white"] [/TD]
[TD="class: xl64, width: 302, bgcolor: white"] [/TD]
[TD="class: xl64, width: 170, bgcolor: white"] [/TD]
[/TR]
[TR]
[TD="class: xl64, width: 95, bgcolor: white"]ZEESHAN[/TD]
[TD="class: xl65, width: 120, bgcolor: white"]15-Feb-12[/TD]
[TD="class: xl64, width: 64, bgcolor: white"] [/TD]
[TD="class: xl64, width: 302, bgcolor: white"] [/TD]
[TD="class: xl64, width: 170, bgcolor: white"] [/TD]
[/TR]
[TR]
[TD="class: xl64, width: 95, bgcolor: white"]SADFER[/TD]
[TD="class: xl65, width: 120, bgcolor: white"]5-Mar-12[/TD]
[TD="class: xl64, width: 64, bgcolor: white"] [/TD]
[TD="class: xl64, width: 302, bgcolor: white"] [/TD]
[TD="class: xl64, width: 170, bgcolor: white"] [/TD]
[/TR]
</tbody>[/TABLE]


Sheet1, A:B, houses the sample you provided. Adjust to suit.

E2: 1-Feb-12 (a month/year of interest, given as the first day date)

Define Ivec using Insert | Name | Define or Formulas | Name Manager as referring to:
Rich (BB code):
=ROW(Sheet1!$A$2:$A$15)-ROW(Sheet1!$A$2)+1

D1, control+shift+enter, not just enter:
Rich (BB code):
=SUM(IF(FREQUENCY(IF(A2:A15<>"",IF(B2:B15-DAY(B2:B15)+1=$E2,
  MATCH(A2:A15,A2:A15,0))),Ivec),1))

D3, control+shift+enter and copy down:
Rich (BB code):
=IF(ROWS($D$3:D3)<=$D$1,INDEX($A$2:$A$15,SMALL(IF(FREQUENCY(IF($A$2:$A$15<>"",
  IF($B$2:$B$15-DAY($B$2:$B$15)+1=$E$2,MATCH($A$2:$A$15,$A$2:$A$15,0))),
   Ivec),Ivec),ROWS($D$3:D3))),"")
 
Upvote 0
Thanks alot both of your.. specially alladin,,
please tell me. can we fix date with max of date range ..
like .. insteed of putting date manually. i like excel to take the max date of a range ,.,=max(a1:a10).

i tried it, but it didnt work..
 
Upvote 0
Thanks alot both of your.. specially alladin,,

You are welcome.

please tell me. can we fix date with max of date range ..
like .. insteed of putting date manually. i like excel to take the max date of a range ,.,=max(a1:a10).

i tried it, but it didnt work..

Do you mean to replace the manual date entry in E2. If so:

=MAX(B2:B15)-DAY(MAX(B2:B15))+1
 
Upvote 0
one thing more..
i am trying for sort (A-Z), but i guess its not workind due to array,
i tried to do with it table and filter option...

is there any way to do it?
 
Upvote 0
Thanks .... All is well now..
one thing more...
is there any possiblity to get the unique records within the selected date range...
like last 12 months?

please help
 
Upvote 0
Thanks .... All is well now..
one thing more...
is there any possiblity to get the unique records within the selected date range...
like last 12 months?

please help

Consider...
[TABLE="width: 401"]
<colgroup><col style="width: 58pt; mso-width-source: userset; mso-width-alt: 2730;" width="77"> <col style="width: 62pt; mso-width-source: userset; mso-width-alt: 2929;" width="82"> <col style="width: 25pt; mso-width-source: userset; mso-width-alt: 1166;" width="33"> <col style="width: 256pt; mso-width-source: userset; mso-width-alt: 12117;" width="341"> <tbody>[TR]
[TD="class: xl66, width: 77, bgcolor: transparent"] [/TD]
[TD="class: xl66, width: 82, bgcolor: transparent"] [/TD]
[TD="class: xl66, width: 33, bgcolor: transparent"] [/TD]
[TD="class: xl64, width: 341, bgcolor: white"]2[/TD]
[/TR]
[TR]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl65, width: 341, bgcolor: white"]1-Mar-12[/TD]
[/TR]
[TR]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl65, width: 341, bgcolor: white"]1-Jan-12[/TD]
[/TR]
[TR]
[TD="class: xl63, width: 77, bgcolor: white"]NAMES[/TD]
[TD="class: xl63, width: 82, bgcolor: white"]DATE[/TD]
[TD="class: xl64, width: 33, bgcolor: white"] [/TD]
[TD="class: xl64, width: 341, bgcolor: white"]5[/TD]
[/TR]
[TR]
[TD="class: xl64, width: 77, bgcolor: white"]JOHN[/TD]
[TD="class: xl65, width: 82, bgcolor: white"]5-Jan-12[/TD]
[TD="class: xl64, width: 33, bgcolor: white"] [/TD]
[TD="class: xl64, width: 341, bgcolor: white"]UNIQUE RECORDf OF LAST 2 MONTH(S)[/TD]
[/TR]
[TR]
[TD="class: xl64, width: 77, bgcolor: white"]FAIZAN[/TD]
[TD="class: xl65, width: 82, bgcolor: white"]6-Jan-12[/TD]
[TD="class: xl64, width: 33, bgcolor: white"] [/TD]
[TD="class: xl64, width: 341, bgcolor: white"]JOHN[/TD]
[/TR]
[TR]
[TD="class: xl64, width: 77, bgcolor: white"]ZEESHAN[/TD]
[TD="class: xl65, width: 82, bgcolor: white"]5-Jan-12[/TD]
[TD="class: xl64, width: 33, bgcolor: white"] [/TD]
[TD="class: xl64, width: 341, bgcolor: white"]FAIZAN[/TD]
[/TR]
[TR]
[TD="class: xl64, width: 77, bgcolor: white"]FAIZAN[/TD]
[TD="class: xl65, width: 82, bgcolor: white"]10-Jan-12[/TD]
[TD="class: xl64, width: 33, bgcolor: white"] [/TD]
[TD="class: xl64, width: 341, bgcolor: white"]ZEESHAN[/TD]
[/TR]
[TR]
[TD="class: xl64, width: 77, bgcolor: white"]ZEESHAN[/TD]
[TD="class: xl65, width: 82, bgcolor: white"]15-Jan-12[/TD]
[TD="class: xl64, width: 33, bgcolor: white"] [/TD]
[TD="class: xl64, width: 341, bgcolor: white"]SALMAN[/TD]
[/TR]
[TR]
[TD="class: xl64, width: 77, bgcolor: white"]FAIZAN[/TD]
[TD="class: xl65, width: 82, bgcolor: white"]25-Jan-12[/TD]
[TD="class: xl64, width: 33, bgcolor: white"] [/TD]
[TD="class: xl64, width: 341, bgcolor: white"]SADFER[/TD]
[/TR]
[TR]
[TD="class: xl64, width: 77, bgcolor: white"]JOHN[/TD]
[TD="class: xl65, width: 82, bgcolor: white"]5-Feb-12[/TD]
[TD="class: xl64, width: 33, bgcolor: white"] [/TD]
[TD="class: xl64, width: 341, bgcolor: white"] [/TD]
[/TR]
[TR]
[TD="class: xl64, width: 77, bgcolor: white"]SALMAN[/TD]
[TD="class: xl65, width: 82, bgcolor: white"]15-Feb-12[/TD]
[TD="class: xl64, width: 33, bgcolor: white"] [/TD]
[TD="class: xl64, width: 341, bgcolor: white"] [/TD]
[/TR]
[TR]
[TD="class: xl64, width: 77, bgcolor: white"]FAIZAN[/TD]
[TD="class: xl65, width: 82, bgcolor: white"]20-Feb-12[/TD]
[TD="class: xl64, width: 33, bgcolor: white"] [/TD]
[TD="class: xl64, width: 341, bgcolor: white"] [/TD]
[/TR]
[TR]
[TD="class: xl64, width: 77, bgcolor: white"]FAIZAN[/TD]
[TD="class: xl65, width: 82, bgcolor: white"]21-Feb-12[/TD]
[TD="class: xl64, width: 33, bgcolor: white"] [/TD]
[TD="class: xl64, width: 341, bgcolor: white"] [/TD]
[/TR]
[TR]
[TD="class: xl64, width: 77, bgcolor: white"]FAIZAN[/TD]
[TD="class: xl65, width: 82, bgcolor: white"]25-Feb-12[/TD]
[TD="class: xl64, width: 33, bgcolor: white"] [/TD]
[TD="class: xl64, width: 341, bgcolor: white"] [/TD]
[/TR]
[TR]
[TD="class: xl64, width: 77, bgcolor: white"]ZEESHAN[/TD]
[TD="class: xl65, width: 82, bgcolor: white"]28-Feb-12[/TD]
[TD="class: xl64, width: 33, bgcolor: white"] [/TD]
[TD="class: xl64, width: 341, bgcolor: white"] [/TD]
[/TR]
[TR]
[TD="class: xl64, width: 77, bgcolor: white"]ZEESHAN[/TD]
[TD="class: xl65, width: 82, bgcolor: white"]15-Feb-12[/TD]
[TD="class: xl64, width: 33, bgcolor: white"] [/TD]
[TD="class: xl64, width: 341, bgcolor: white"] [/TD]
[/TR]
[TR]
[TD="class: xl64, width: 77, bgcolor: white"]SADFER[/TD]
[TD="class: xl65, width: 82, bgcolor: white"]5-Mar-12[/TD]
[TD="class: xl64, width: 33, bgcolor: white"] [/TD]
[TD="class: xl64, width: 341, bgcolor: white"] [/TD]
[/TR]
</tbody>[/TABLE]


A4:B18 houses the relevant data.

D1: 2 (The parameter value specifying "last N months"; Adjust to suit.)

D2, just enter:
Rich (BB code):
=MAX(B5:B18)-DAY(MAX(B5:B18))+1

The foregoing etermines the last month of the year in the data in the form of a first day date.

D3, just enter:
Rich (BB code):
=EDATE(D2,-D1)

This determines the start month/year of the last N months streak.

D4, control+shift+enter, not just enter:
Rich (BB code):
=SUM(IF(FREQUENCY(IF(A5:A18<>"",
  IF(B5:B18-DAY(B5:B18)+1>=EDATE(D2,-D1),
   MATCH(A5:A18,A5:A18,0))),Ivec),1))

Thi calculates the number of unique records in the last N months.

D6, control+shift+enter, not just enter, and copy down:
Rich (BB code):
=IF(ROWS($D$6:D6)<=$D$4,INDEX($A$5:$A$18,
  SMALL(IF(FREQUENCY(IF($A$5:$A$18<>"",
   IF($B$5:$B$18-DAY($B$5:$B$18)+1>=EDATE($D$2,-$D$1),
    MATCH($A$5:$A$18,$A$5:$A$18,0))),Ivec),Ivec),ROWS($D$6:D6))),"")

Finally, this lists the unique (distinct) records of the last N months.
 
Upvote 0
Thank you very much Aladin

Could you please also tell me. if we need the unique list of only last 12 month data..then what would be the formula.
 
Upvote 0

Forum statistics

Threads
1,223,247
Messages
6,171,007
Members
452,374
Latest member
keccles

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