Trouble with not/in expression

Hi!

I’m struggling with this expression, help!

It’s working fine when it comes to not let me put an existing data in the columm “FINALIDADE”. However, I just wanted it to not let me duplicate this data when I’m adding a new form but now it’s not letting me edit an existing one.

NOT(
IN([_THISROW].[FINALIDADE], SELECT(SAI_HEADER[FINALIDADE],
AND([FINALIDADE]=[FINALIDADE],[FINALIDADE]<>“USO E CONSUMO”,
[FINALIDADE]<>“0 - EMPRESA”,[FINALIDADE]<>“ALMOXARIFADO”,
[FINALIDADE]<>“AMOSTRA”,[FINALIDADE]<>“ASSISTÊNCIAS EM GERAL”,
[FINALIDADE]<>“COMPRA DE TERCEIROS”,[FINALIDADE]<>“DEVOLUÇÃO”,
[FINALIDADE]<>“DOAÇÃO / BRINDE”,[FINALIDADE]<>“EMPRESTADO”,
[FINALIDADE]<>“NÃO INFORMADO”,[FINALIDADE]<>“USO PARTICULAR MARROM”))))

P.S. those inside the AND espression are exceptions that allows me to use them whenever I want.

This collum is a ref. that brings a list of values.

Here it’s what happens when I try to edit other columm in this form. If I want to change the “RESPONSÁVEL” I cannot do it.

You probably need to remove the current row from the list of rows against which it’s being compared. The concepts explained How to Prevent Duplicate Records - Google Cloud Community in can likely help.