Hi @PickleRick , I tested your suggestion and it worked. Thank you for your help. 1) I added one more case where the IP has an empty name. I added condition in the where clause (dc=0) and it worked. I am afraid if I used isnull(name), sometimes it contains " " (empty string). Please let me know if this is doable 2) Is it possible to do this without using eventstat? I have already used eventstats in the search, but for a different field Will that cause any delays or issues? Did you ever use multiple eventstats in your search? Thank you so much for your help ip name location 1.1.1.1 name0 location-1 1.1.1.1 name1 location-1 1.1.1.2 name2 location-2 1.1.1.2 name0 location-20 1.1.1.3 name0 location-3 1.1.1.3 name3 location-3 1.1.1.4 name4 location-4 1.1.1.4 name4b location-4 1.1.1.5 name0 location-0 1.1.1.6 name0 location-0 1.1.1.7 location-7 | makeresults format=csv data="ip, name, location
1.1.1.1, name0, location-1
1.1.1.1, name1, location-1
1.1.1.2, name2, location-2
1.1.1.2, name0, location-20
1.1.1.3, name0, location-3
1.1.1.3, name3, location-3
1.1.1.4, name4, location-4
1.1.1.4, name4b, location-4
1.1.1.5, name0, location-0
1.1.1.6, name0, location-0
1.1.1.7,,location-7"
| eventstats dc(name) AS dc BY ip
| where name!="name0" OR dc=0 OR (name=="name0" AND dc=1)
... View more