Check values of one strings "," seperated againts another strings of values "," seperated

I have a strings of values called CATEGORY_FILTER, “,” seperated, and want to have a comparison againts another string “,” sperated called “parent_pulled”, I want to chek if any values within the parent_pulled matches in the CATEGORY_FILTER,

example 1: CATEGORY_FILTER, " 13391,8229,8986,8974" and “parent_pulled”; “5445,6851,8974” , I want the result of the calculation to be “TRUE” as 8974 from parent_pulled exist in CATEGORY_FILTER

example 1: CATEGORY_FILTER, " 13391,8229,8986,8974" and “parent_pulled” : “5445,6851,12” I want the result of the calculation to be “FALSE” as non of the values in parent_pulled exist in CATEGORY_FILTER,

In the first string (parent_pulled) you could replace the , (comma) by blank, using translate() into a new space-separated string (needle role). Then you can treat this new string like a multiple select, getting each part with the selected_at() and the number of elements with count-selected(). With a repeat, you can walk through the first string and test for each element if you can find it in the second string (CATEGORY_FILTER, haystack role), using contains(). To optimize performance, you can use the string with less elements as needle and the longer one as haystack (to search in)…
For all functions see: ODK XForms Specification.

1 Like