diff --git a/toardb/utils/utils.py b/toardb/utils/utils.py
index cf11abdb410f7440fc49125602af9101a40d109b..2f4f23b652f8ca675df11e091a6b6d0ae2111780 100644
--- a/toardb/utils/utils.py
+++ b/toardb/utils/utils.py
@@ -60,7 +60,6 @@ def translate_convoc_list(values, table, display_name):
     except ValueError:
         raise HTTPException(status_code=470, detail=f"{display_name} not known: {values}")
 
-
 #
 def create_filter(query_params, endpoint):
 
@@ -132,15 +131,21 @@ def create_filter(query_params, endpoint):
             elif param == "data_origin":
                 values = translate_convoc_list(values, toardb.toardb.DO_vocabulary, "data origin")
             if param == "has_role":
-                t_r_filter.append(f"organisations.longname IN {values}")
-                t_r_filter.append(f"organisations.name IN {values}")
-                t_r_filter.append(f"organisations.city IN {values}")
-                t_r_filter.append(f"organisations.homepage IN {values}")
-                t_r_filter.append(f"organisations.contact_url IN {values}")
-                t_r_filter.append(f"persons.email IN {values}")
-                t_r_filter.append(f"persons.name IN {values}")
-                t_r_filter.append(f"persons.orcid IN {values}")
-                t_r_filter = " OR ".join(t_r_filter)
+                operator = "IN"
+                join_operator = "OR"
+                if (values[0][0] == '~'):
+                    operator = "NOT IN"
+                    join_operator = "AND"
+                    values[0] = values[0][1:]
+                t_r_filter.append(f"organisations.longname {operator} {values}")
+                t_r_filter.append(f"organisations.name {operator} {values}")
+                t_r_filter.append(f"organisations.city {operator} {values}")
+                t_r_filter.append(f"organisations.homepage {operator} {values}")
+                t_r_filter.append(f"organisations.contact_url {operator} {values}")
+                t_r_filter.append(f"persons.email {operator} {values}")
+                t_r_filter.append(f"persons.name {operator} {values}")
+                t_r_filter.append(f"persons.orcid {operator} {values}")
+                t_r_filter = f" {join_operator} ".join(t_r_filter)
             else:
                 t_filter.append(f"timeseries.{param} IN {values}")
         elif param in core_params: