Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
hugmarcel
Specialist
Specialist

How to match text to field content in script?

Hi

I have a script statement

.. match('dx',table_field1) where table_field1 contains string 'da;dx;dz'.

Result should be 2 as dx is second element in string compared to 'dx'.

How do I have to transform table_field1 so that I am getting correct result 2?

I tried something like .

match('dx',chr(39) & replace(table_field1,';',chr(39) & ',' & chr(39))  & chr(39))

but this does not work.

Thx - Marcel

3 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

This works:

     =match('dx', $(=chr(39) & Replace(table_field1, ';', chr(39) & ','  & chr(39)) & chr(39)))

(as long as there is only one possible value of table_field1 (at the calculation point))

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
hugmarcel
Specialist
Specialist
Author

Hi Jonathan

i tried this to. It works in a diagram, but not in Script!

In Script, I am getting error

Error in expression:

Match takes at least 2 parameters

Thx - Marcel

hugmarcel
Specialist
Specialist
Author

Hi

I guess I found a solution, I switch the match parameters, use substringcount and index instead:

SUBSTRINGCOUNT(MID(table_field1,1,INDEX(';'&table_field1&';' , ';'&'dx'&';')), ';') + 1

Marcel