Here’s your most recent expression, formatted to my preferences:
IF(
(
ANY(
SELECT(
UTENTI[BASE TRAPANI],
([NOME UTENTE] = USERSETTINGS("NOME UTENTE"))
)
)
= "SI"
),
([BASE] = "TRAPANI"),
IF(
(
ANY(
SELECT(
UTENTI[BASE SAN VITO],
([NOME UTENTE] = USERSETTINGS("NOME UTENTE"))
)
)
= "SI"
),
([BASE] = "SAN VITO"),
IF(
(
ANY(
SELECT(
UTENTI[BASE CASTELLAMMARE],
([NOME UTENTE] = USERSETTINGS("NOME UTENTE"))
)
)
= "SI"
),
([BASE] = "CASTELLAMMARE"),
ISNOTBLANK(ESCURSIONI[ID PRENOTAZIONE])
)
)
)
If the BASE TRAPANI, BASE SAN VITO, and BASE CASTELLAMMARE columns are of type Yes/No, you need not compare their values to “SI”, but can instead use them directly:
IF(
ANY(
SELECT(
UTENTI[BASE TRAPANI],
([NOME UTENTE] = USERSETTINGS("NOME UTENTE"))
)
),
([BASE] = "TRAPANI"),
IF(
ANY(
SELECT(
UTENTI[BASE SAN VITO],
([NOME UTENTE] = USERSETTINGS("NOME UTENTE"))
)
),
([BASE] = "SAN VITO"),
IF(
ANY(
SELECT(
UTENTI[BASE CASTELLAMMARE],
([NOME UTENTE] = USERSETTINGS("NOME UTENTE"))
),
([BASE] = "CASTELLAMMARE"),
ISNOTBLANK(ESCURSIONI[ID PRENOTAZIONE])
)
)
)
Rather than IF() expressions within IF() expressions, you could instead use IFS():
IFS(
ANY(
SELECT(
UTENTI[BASE TRAPANI],
([NOME UTENTE] = USERSETTINGS("NOME UTENTE"))
)
),
([BASE] = "TRAPANI"),
ANY(
SELECT(
UTENTI[BASE SAN VITO],
([NOME UTENTE] = USERSETTINGS("NOME UTENTE"))
)
),
([BASE] = "SAN VITO"),
ANY(
SELECT(
UTENTI[BASE CASTELLAMMARE],
([NOME UTENTE] = USERSETTINGS("NOME UTENTE"))
),
([BASE] = "CASTELLAMMARE"),
TRUE,
ISNOTBLANK(ESCURSIONI[ID PRENOTAZIONE])
)
We can improve performance by swapping the order of some comparisons so that the SELECT() expression is only performed if [BASE] matches:
IFS(
([BASE] = "TRAPANI"),
ANY(
SELECT(
UTENTI[BASE TRAPANI],
([NOME UTENTE] = USERSETTINGS("NOME UTENTE"))
)
),
([BASE] = "SAN VITO"),
ANY(
SELECT(
UTENTI[BASE SAN VITO],
([NOME UTENTE] = USERSETTINGS("NOME UTENTE"))
)
),
([BASE] = "CASTELLAMMARE"),
ANY(
SELECT(
UTENTI[BASE CASTELLAMMARE],
([NOME UTENTE] = USERSETTINGS("NOME UTENTE"))
),
TRUE,
ISNOTBLANK(ESCURSIONI[ID PRENOTAZIONE])
)
Because all but one of the IFS() tests is matching [BASE], we could use SWITCH() instead of IFS() for a (trivial) performance boost and to improve readability of the expression:
SWITCH(
[BASE],
"TRAPANI",
ANY(
SELECT(
UTENTI[BASE TRAPANI],
([NOME UTENTE] = USERSETTINGS("NOME UTENTE"))
)
),
"SAN VITO",
ANY(
SELECT(
UTENTI[BASE SAN VITO],
([NOME UTENTE] = USERSETTINGS("NOME UTENTE"))
)
),
"CASTELLAMMARE",
ANY(
SELECT(
UTENTI[BASE CASTELLAMMARE],
([NOME UTENTE] = USERSETTINGS("NOME UTENTE"))
),
ISNOTBLANK(ESCURSIONI[ID PRENOTAZIONE])
)
Looking back at the exchange with @OptimiX_XcrY , it appears your use of the BASE TRAPANI, BASE SAN VITO, and BASE CASTELLAMMARE are probably unnecessary. I suspect we could actually replace even the SWITCH() expression with a much simpler OR():
OR(
ISNOTBLANK(
FILTER(
"UTENTI",
AND(
([_THISROW].[BASE] = [BASE]),
([NOME UTENTE] = USERSETTINGS("NOME UTENTE"))
)
)
),
ISNOTBLANK(ESCURSIONI[ID PRENOTAZIONE])
)