Search code examples
filemaker

Update field with partial match


i have a parsing calculation in a field called "output" that looks at another field (called "parser") and updates "output" with a portion of the data from "parser" (specifically, The data is "XCX0001-user", the calculation looks for "-user" and then updates the output field with "XCX001").

Here is what I have so far:

If ( FilterValues ( layout::parser ; "-user" )  ; 
Left ( layout::parser ; Position ( layout::parser ; "-" ; 1 ; 1 ) -1 ) 
; 0 )

So if the field doesnt have the "-user" portion, it will print a '0', not "XCX001". Though it doesnt look like "Filter Values" looks for partial matches. Any way to fix this?

Thanks.


Solution

  • FilterValues() does not do what you think it does (see the help for more).

    To test if your field contains the string "-user", you can use =

    PatternCount ( YourField ; "-user" )
    

    or =

    Position ( YourField ; "-user" ; 1 ; 1  )
    

    as your test expression. Alternatively, if the string is always at the end, you could test for =

    Right ( YourField ; 5  ) =  "-user"