Extract unique records with date criteria: between 2 dates

carlmov

New Member
Joined
Jun 23, 2017
Messages
16
DATEREGIONLOWER:1/14/2016
1/11/2016WESTUPPER:1/20/2016
1/12/2016EASTunique values
1/13/2016WESTREGION
1/14/2016NORTHNORTHWEST
1/12/2016SOUTHNORTHWEST
1/16/2016NORTHNORTHWEST
1/17/2016NORTHEASTWEST
1/13/2016SOUTHWESTWEST
1/19/2016EASTWEST
1/20/2016WESTWEST
1/16/2016NORTHWEST
1/22/2016SOUTH

<tbody>
</tbody>

Columns: Dates = A, Region = B, etc..

I want to extract only unique records for dates between D1 and D2
The formula below (under Region in red, gives me all records between the dates:

=IFERROR(INDEX($B$2:$B$13,SMALL(IF($A$2:$A$13>=$D$1,IF($A$2:$A$13<=$D$2,ROW($B$2:$B$13)-ROW($B$2)+1)),ROWS($D$5:D5))),"") there was a slight mistake here A2:A13 not A2:A11 sorry

I want to extract only the unique records but it always gives me the same first one although in formula evaluator i get the right row number!!

=IFERROR(INDEX($B$2:$B$13,IF($A$2:$A$13>=$D$1,IF($A$2:$A$13<=$D$2,SMALL(IF(FREQUENCY(MATCH($B$2:$B$13,$B$2:$B$13,0),ROW($B$2:$B$13)-ROW($B$2)+1),ROW($B$2:$B$13)-ROW($B$2)+1),ROWS($E$5:E5))))),"")


Please can anyone help? I don't know what I am doing wrong

Thank you so much

carlo
 
If the ID criteria is in Cell A16 where is the date column? As Mr. Branco replied to your formula - that works too. So you have to determine the date criteria and ID criteria corresponds to which columns. Good luck
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
If the ID criteria is in Cell A16 where is the date column? As Mr. Branco replied to your formula - that works too. So you have to determine the date criteria and ID criteria corresponds to which columns. Good luck

Nice one, Marcelo! Thanks for your help as it works perfectly fine!

carlmov, sorry for the confusion caused. The ID input field is in Cell A16 of my current worksheet whereas the Date column is in Column A of another worksheet where I need my data to be extracted from :)
 
Upvote 0
Maybe this...


A
B
C
D
1
DATE​
REGION​
LOWER:​
01/14/2016​
2
01/11/2016​
WEST​
UPPER:​
01/20/2016​
3
01/12/2016​
EAST​
4
01/13/2016​
WEST​
REGION​
5
01/14/2016​
NORTH​
EAST​
6
01/12/2016​
SOUTH​
NORTH​
7
01/16/2016​
NORTH​
WEST​
8
01/17/2016​
NORTH​
9
01/13/2016​
SOUTH​
10
01/19/2016​
EAST​
11
01/20/2016​
WEST​
12
01/16/2016​
NORTH​
13
01/22/2016​
SOUTH​

<tbody>
</tbody>


Array formula in D5 copied down
=IFERROR(INDEX($B$2:$B$13,MATCH(0,IF(A$2:A$13>=D$1,IF(A$2:A$13<=D$2,COUNTIFS(B$2:B$13,"<"&B$2:B$13,A$2:A$13,">="&D$1,A$2:A$13,"<="&D$2)-SUM(COUNTIF(D$4:D4,IF(A$2:A$13>=D$1,IF(A$2:A$13<=D$2,B$2:B$13)))))),0)),"")
Ctrl+Shift+Enter

M.

Hello, good day, can you modify this formula for use with table references instead of ranges?
 
Last edited:
Upvote 0
Hello, good day, can you modify this formula for use with table references instead of ranges?

Assuming the table name is Table1 (adjust to suit) all you have to do is to replace:
every instance of $A$2:$A$13 by Table1[DATE]
and
every instance of $B$2:$B$13 by Table1[REGION]

M.
 
Upvote 0
Assuming the table name is Table1 (adjust to suit) all you have to do is to replace:
every instance of $A$2:$A$13 by Table1[DATE]
and
every instance of $B$2:$B$13 by Table1[REGION]

M.

Works great but I have to still reference D$4:D4. If I am putting the results in another table how do I enter this part because Table[#Headers] is not working.
 
Upvote 0
Sometimes table references complicate things. On the other hand, I do not see any problem in using D$4:D4

M.
 
Upvote 0
Ok thank you. I am using your formula for payroll. Payroll is done fortnightly but I have a time-sheet that records the times daily. How do I extract the employees worked for each fortnight. For example using the table above, North occurs once between 1-14th and 3 times between 15-31st. I want to get North shown under Region twice (for each fortnight period) or at least for each week ending. North did not occur in the first and last weeks so the results should return North for 2 weeks in January.
 
Upvote 0
Never mind. I just restructured my table to split Gross pay by each week.
 
Upvote 0

Forum statistics

Threads
1,215,373
Messages
6,124,559
Members
449,171
Latest member
jominadeo

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