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

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Try this? Adjust range as needed.
Excel Formula:
=TAKE(FILTER(A1:D10,(B1:B10=J1)*(C1:C10<>"")*NOT(ISNUMBER(SEARCH("SHIP",D1:D10)))),1)
 
Upvote 0
Hey I tried that, the take function wont work as it only takes the first row however i want to take the first row for each contact number

My cells have changed but i managed to tweak to pull back the columns but the end result is still an issue

=FILTER(FILTER(Table1,((Table1[Date]=$L$1)*(Table1[Dept]<>"")*(NOT(ISNUMBER(SEARCH($K$2,Table1[Contact])))))),{1,0,1,1,0})

DatetimeContactDept
01/01/2023 15:06:002477HR
01/01/2023 16:00:002477FINANCE
01/01/2023 16:02:002477FINANCE
01/01/2023 16:05:00500FINANCE
01/01/2023 16:07:00500FINANCE
Final Result
DatetimeContactDept
01/01/2023 15:06:002477HR
01/01/2023 16:05:00500FINANCE
 
Upvote 0
Hey I tried that, the take function wont work as it only takes the first row however i want to take the first row for each contact number

My cells have changed but i managed to tweak to pull back the columns but the end result is still an issue

=FILTER(FILTER(Table1,((Table1[Date]=$L$1)*(Table1[Dept]<>"")*(NOT(ISNUMBER(SEARCH($K$2,Table1[Contact])))))),{1,0,1,1,0})

DatetimeContactDept
01/01/2023 15:06:002477HR
01/01/2023 16:00:002477FINANCE
01/01/2023 16:02:002477FINANCE
01/01/2023 16:05:00500FINANCE
01/01/2023 16:07:00500FINANCE
Final Result
DatetimeContactDept
01/01/2023 15:06:002477HR
01/01/2023 16:05:00500FINANCE
Ah that wasn't clear from the OP.

How about this?
Excel Formula:
=CHOOSEROWS(FILTER(A1:D10,(B1:B10=J1)*(C1:C10<>"")*NOT(ISNUMBER(SEARCH("SHIP",D1:D10)))),MATCH(UNIQUE(D1:D10),D1:D10,0))
where A=Datime, B = Date, C=Dept, D = contact.
 
Upvote 0
And also if i can filter to take the first row for each contact and get the final result

I would like to add another filter to just filter the Dept (I have a separate HR sheet and Finance sheet) so i tried this without any luck

i know i need to get the end final result first - Getting a value error
=FILTER(FILTER(FILTER(Table1,((Table1[Date]=$L$1)*(Table1[Dept]<>"")*(NOT(ISNUMBER(SEARCH($K$2,Table1[Contact])))))),{1,0,1,1,0}),Table1[Dept]=$R$17)


Final Result
DatetimeContactDept
01/01/2023 15:06:002477HR
01/01/2023 16:05:00500FINANCE
Final Result HRFinal Result HRHR
DatetimeContactDeptDatetimeContactDeptFINANCE
01/01/2023 15:06:002477HR#VALUE!
Final Result FINANCE
DatetimeContactDept
01/01/2023 16:05:00500FINANCE
 
Upvote 0
And also if i can filter to take the first row for each contact and get the final result

I would like to add another filter to just filter the Dept (I have a separate HR sheet and Finance sheet) so i tried this without any luck

i know i need to get the end final result first - Getting a value error
=FILTER(FILTER(FILTER(Table1,((Table1[Date]=$L$1)*(Table1[Dept]<>"")*(NOT(ISNUMBER(SEARCH($K$2,Table1[Contact])))))),{1,0,1,1,0}),Table1[Dept]=$R$17)


Final Result
DatetimeContactDept
01/01/2023 15:06:002477HR
01/01/2023 16:05:00500FINANCE
Final Result HRFinal Result HRHR
DatetimeContactDeptDatetimeContactDeptFINANCE
01/01/2023 15:06:002477HR#VALUE!
Final Result FINANCE
DatetimeContactDept
01/01/2023 16:05:00500FINANCE
Did the formula in post#4 work for you for the non-blank Dept?

If it did then change the C1:C10 condition to..
Excel Formula:
=CHOOSEROWS(FILTER(A1:D10,(B1:B10=J1)*(C1:C10=$R$17)*NOT(ISNUMBER(SEARCH("SHIP",D1:D10)))),MATCH(UNIQUE(D1:D10),D1:D10,0))

for your specific finance, and HR sheet.
 
Upvote 0
Thank you - i tried that but getting a value error

=CHOOSEROWS(FILTER(Table1[[#All],[Datetime]:[Contact]],(Table1[[#All],[Date]]=$L$1)*(Table1[[#All],[Dept]]<>"")*NOT(ISNUMBER(SEARCH($K$2,Table1[[#All],[Contact]])))),MATCH(UNIQUE(Table1[[#All],[Contact]]),Table1[[#All],[Contact]],0))
 
Upvote 0
It worked for me.

Book2
ABCDEFGHIJKL
1DatetimeDATEContactDept1/1/23
21/1/23 15:061/1/232477HRResultSHIP
31/1/23 16:001/1/232477FINANCE1/1/23 15:061/1/232477HR
41/1/23 16:021/1/232477FINANCE1/1/23 16:051/1/23500FINANCE
51/1/23 16:051/1/23500FINANCE
61/1/23 16:071/1/23500FINANCE
Sheet2
Cell Formulas
RangeFormula
G3:J4G3=CHOOSEROWS(FILTER(Table1,(Table1[DATE]=$L$1)*(Table1[Dept]<>"")*(NOT(ISNUMBER(SEARCH($K$2,Table1[Dept]))))),MATCH(UNIQUE(Table1[Contact]),Table1[Contact],0))
Dynamic array formulas.
 
Upvote 0
dont know why im getting that value error

The evaluate up until choose rows looks like this

=CHOOSEROWS({44927.6291666667,44927,"HR",2477,"No";44927.6666666667,44927,"FINANCE",2477,"No";44927.6680555556,44927,"FINANCE",2477,"No";44927.66875,44927,"FINANCE","SHIP","No";44927.6694444444,44927,"HR","SHIP","No";44927.6701388889,44927,"FINANCE",500,"No";44927.6715277778,44927,"FINANCE",500,"No"},{1;6;8})
 
Upvote 0
I think the error is because the match unique is trying to filter the an additional unique value (row 8)?
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,954
Members
449,095
Latest member
nmaske

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