Using Filtering to exclude employees by name

I’ve successfully got filtering setup inclusively for some charts by doing this:

function(itemData){

return (itemData["UserName"].contains ("name@domain.com")) || 
(itemData["UserName"].contains ("firstname@domains.com")) ||
(itemData["Department"].contains ("FEM")) ||
(itemData["Department"].contains ("ManufacturerName"))  ;	
}

But now I need to filter on another chart to exclude several employees. (Identifying them by email address is sufficient.) I can’t figure out what argument to write to do this. Basically I want to say “don’t show person with email address name@domain.com.”

Success! This works for a single person:

function(itemData){
return (itemData["UserName"] != ("name@domain.com"));
}

And for multiple people:

function(itemData){
return (itemData["UserName"] != ("name@domain.com")) &
(itemData["UserName"] != ("name2@domain.com")) ;
}
1 Like

Hi @Reasonfull,

Great! Thank you for sharing your results.

Is there a way to exclude users by a search string. for eg how do I exclude users that have admin at the end of the username?

Hello @PACTGROUP,

You can exlude users with the “admin” string in the UserName like this:

!itemData["UserName"].contains("admin"));
or
!itemData["UserName"].contains("admin@"));

So, the filtration rule to exclude users with particular email addresses plus users with the “admin” string in their email address will look like this:

function(itemData){
return (itemData["UserName"] != ("name@domain.com") &
itemData["UserName"] != ("name2@domain.com") & !itemData["UserName"].contains("admin"));
}

Best Regards,
Anna Dorokhova
Plumsail Team