Help with contains() + parameter in calculated field — “incorrect argument type” error

Hi everyone,

I’m running into a syntax / type-mismatch error when I try to use a parameter inside a contains() filter.

What I’m trying to do

I have a text field LOC_ORIGEM with values like:

A.04.313
B.03.543
B.04.312
C.02.412

My goal is to let the reader choose a prefix (A, B, C…) and automatically filter the visuals to show only rows whose LOC_ORIGEM starts with that letter.

Parameter

  • Name: PrefixoArea
  • Type: String
  • Values: A, B, C (single select)
  • Control: dropdown shown in the analysis

Error message:
Expression {{argumentName}} for function {{functionName}} has incorrect argument type {{incorrectArgumentType}}.
Function syntax expects {{functionSignature}}.

Calculated field

ifelse(
    contains({LOC_ORIGEM}, ${PrefixoArea}),  -- this line errors
    1,
    0
)

Thanks in advance for any pointers!

Hi there, thanks for your questions. Seems like Contains won’t handle a multi-parameter. Can you modify your calculated field to use the In function? Just replace Contains with In.
Thanks,
Asem

2 Likes

Thank you for the fast and helpful replies. Your explanations made the issue crystal-clear, and the solution you suggested worked perfectly in my analysis.
João

1 Like

That great to hear. Glad it worked for you!

1 Like