Forum Discussion
IN operator
- 1 year ago
Hey Peter_23
I initially confused the concepts π .
EXISTSis a logical operator in SQL, used to check the existence of rows in a subquery. However, there is no directEXISTSfunction in DAX.In DAX, similar logic can be achieved by using functions like
CALCULATEcombined withCOUNTROWSto check if specific conditions are met.
Hereβs a cleaner version of your query:EVALUATE
VAR MatchCheck =
CALCULATE(
COUNTROWS(USER),
USER[ID] = FACT[ID_USER],
USER[COUNTRY] = "US"
)RETURN
SWITCH(
TRUE(),
MatchCheck > 0, TRUE(),
FALSE()
)
Oh, you're right! marcelsmaglhaes
Remarks
Except syntax, the IN operator and CONTAINSROW function are functionally equivalent.
and what do you mean with "EXISTS" ? I guess command.. π€
Hey Peter_23
I initially confused the concepts π
. EXISTS is a logical operator in SQL, used to check the existence of rows in a subquery. However, there is no direct EXISTS function in DAX.
In DAX, similar logic can be achieved by using functions like CALCULATE combined with COUNTROWS to check if specific conditions are met.
Hereβs a cleaner version of your query:
EVALUATE
VAR MatchCheck =
CALCULATE(
COUNTROWS(USER),
USER[ID] = FACT[ID_USER],
USER[COUNTRY] = "US"
)
RETURN
SWITCH(
TRUE(),
MatchCheck > 0, TRUE(),
FALSE()
)
- Peter_231 year ago
Advocate V
That's OK marcelsmaglhaes Don't worry be happy π