Filter First Unique value

Uzma Shaheen

Active Member
Joined
Nov 10, 2012
Messages
484
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
  2. Mobile
  3. Web
Hey is it possible to use the Filter function to filter my data in a specific order and the give me me the first unique value for that contact number on that date?

For example

Say i have data like this (data is sorted by contact and then datetime)

DateTime…Date….Dept…Contact
01/10 16:06 01/10 Finance 0267
01/10 16:55 01/10 HR. 0267
01/10. 16:78 01/10 0267

In example above

1) I want filter on the date = to cell J1
2) Dept <> “”
3) Contact to exclude anything that has the word SHIP in it

I would want the data to then look like this based on above conditions

DateTime…Date….Dept…Contact
01/10 16:06 01/10 Finance 0267
01/10 16:55 01/10 HR. 0267

And then using that data - filter on DateTime to give first unique value for that contact/first contact occurrence details

End Result (this is the first record for that contact number from filtered list on that date)

DateTime…Date….Dept…Contact
01/10 16:06 01/10 Finance 0267
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
There is yep but shouldnt be returned

example dataset below

DatetimeDateDeptContact
44927.62501/01/20232477
44927.6256901/01/20232477
44927.6291701/01/2023HR2477
44927.6666701/01/2023FINANCE2477
44927.6680601/01/2023FINANCE2477
44927.6687501/01/2023FINANCESHIP
44927.6694401/01/2023HRSHIP
44927.6701401/01/2023FINANCE500
44927.6715301/01/2023FINANCE500
44928.6708302/01/2023FINANCE500
44929.6687503/01/2023HR500
44929.6673603/01/2023FINANCESHIP
44929.6680603/01/2023FINANCESHIP
44929.6687503/01/2023SHIPSHIP
44929.6694403/01/2023SHIPSHIP
 
Upvote 0
in the output based on the data it returns 5 rows and it should give back row 1 and row 4 as thats the first row for that contact number
the unique function i can see would work but because it spills out that extra row will cause issue

DatetimeDateDeptContact
01/01/2023 15:06:0044927HR24771
01/01/2023 16:00:0044927FINANCE2477
01/01/2023 16:02:0044927FINANCE2477
01/01/2023 16:05:0044927FINANCE5004
01/01/2023 16:07:0044927FINANCE500
 
Upvote 0
the match needs to be spilling out 1 and 4 based on the filtered table - i guess need to return the 1st position of that contact in filtered table then next position of next contact but wont have a clue on how to do that
 
Upvote 0
This looks terrible but..
Book2
ABCDEFGHIJKL
1DatetimeDateDeptContact1/1/23
244927.6251/1/232477DatetimeDateDeptContactSHIP
344927.62571/1/2324771/1/23 15:061/1/23HR2477
444927.62921/1/23HR24771/1/23 16:051/1/23FINANCE500
544927.66671/1/23FINANCE2477
644927.66811/1/23FINANCE2477
744927.66881/1/23FINANCESHIP
844927.66941/1/23HRSHIP
944927.67011/1/23FINANCE500
1044927.67151/1/23FINANCE500
1144928.67082/1/23FINANCE500
1244929.66883/1/23HR500
1344929.66743/1/23FINANCESHIP
1444929.66813/1/23FINANCESHIP
1544929.66883/1/23SHIPSHIP
1644929.66943/1/23SHIPSHIP
Sheet2
Cell Formulas
RangeFormula
G3:J4G3=LET(f,FILTER(Table1,(Table1[Date]=$L$1)*(Table1[Dept]<>"")*(NOT(ISNUMBER(SEARCH($K$2,Table1[Contact]))))),CHOOSEROWS(f,MATCH(UNIQUE(FILTER(Table1[Contact],Table1[Contact]<>$K$2)),CHOOSECOLS(f,4),0)))
Dynamic array formulas.
 
Upvote 0
Let me give that a go :) - thank you - really appreciate it

Would this be dynamic too?
 
Upvote 0
That seems to work beautifully - thank you

Trying to understand the let bit of the function

The thing that doesnt work is if i wanted to filter just the Dept for my other sheets i mentioned so need to tweak slightly when i input formula on its own sheet too

i tried

=LET(f,FILTER(Table1,(Table1[Date]=$L$1)*(Table1[Dept]<>"")*(Table1[Dept]=$R$17)*(NOT(ISNUMBER(SEARCH($K$2,Table1[Contact]))))),CHOOSEROWS(f,MATCH(UNIQUE(FILTER(Table1[Contact],Table1[Contact]<>$K$2)),CHOOSECOLS(f,4),0)))
 
Upvote 0
sorry i seen hard coded 4 in choose cols and thought it wont be dynamic - my bad
 
Upvote 0
That seems to work beautifully - thank you

Trying to understand the let bit of the function

The thing that doesnt work is if i wanted to filter just the Dept for my other sheets i mentioned so need to tweak slightly when i input formula on its own sheet too

i tried

=LET(f,FILTER(Table1,(Table1[Date]=$L$1)*(Table1[Dept]<>"")*(Table1[Dept]=$R$17)*(NOT(ISNUMBER(SEARCH($K$2,Table1[Contact]))))),CHOOSEROWS(f,MATCH(UNIQUE(FILTER(Table1[Contact],Table1[Contact]<>$K$2)),CHOOSECOLS(f,4),0)))
Can you share a sample of your department-specific sheet and what's the desired output? It might not be this complicated.
 
Upvote 0

Forum statistics

Threads
1,215,071
Messages
6,122,963
Members
449,094
Latest member
Anshu121

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