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 ("[email protected]")) || 
(itemData["UserName"].contains ("[email protected]")) ||
(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 [email protected].”

Success! This works for a single person:

function(itemData){
return (itemData["UserName"] != ("[email protected]"));
}

And for multiple people:

function(itemData){
return (itemData["UserName"] != ("[email protected]")) &
(itemData["UserName"] != ("[email protected]")) ;
}
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("[email protected]"));

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"] != ("[email protected]") &
itemData["UserName"] != ("[email protected]") & !itemData["UserName"].contains("admin"));
}

Best Regards,
Anna Dorokhova
Plumsail Team