Qlik Community

QlikView Documents

Documents for QlikView related information.

StrCmp Function


StrCmp Function

As long as I remember, there is a C/C++ function called StrCmp() , which returns the first mismatch position of two strings. I have created a function based on a user's requirement which needs find how long the strings match with each other. Created the function in VB Script and called the function in script.

Qv Doc Post.png

I thought, it might help some other people.

Labels (2)
Contributor III

Hi, could be interesting to know how to enable function use in an expression.

Do right-click on the QlikView ball in the lower, left-hand corner. In the Settings menu that appears, locate and select the AllowMacroFunctionInExpressions option.

Enter the value of 1 and click on Set. Close window and reload document.


New Contributor III

That is pretty cool hidden setting. Unfortunately in practice it is much less useful if all the clients need to apply the same setting manually. Any idea if this could be set from the document by a macro?

If the amounts of data aren't too large you could try it with an ugly solution like this:

=if(mid(Str1, 1, 1) <> mid(Str2, 1, 1), 1,

  if(mid(Str1, 2, 1) <> mid(Str2, 2, 1), 2,

  if(mid(Str1, 3, 1) <> mid(Str2, 3, 1), 3,

  if(mid(Str1, 4, 1) <> mid(Str2, 4, 1), 4,

  if(mid(Str1, 5, 1) <> mid(Str2, 5, 1), 5,

  if(mid(Str1, 6, 1) <> mid(Str2, 6, 1), 6,

  if(mid(Str1, 7, 1) <> mid(Str2, 7, 1), 7,

  if(mid(Str1, 8, 1) <> mid(Str2, 8, 1), 8, '#NV')))))))) - 1

- Marcus

New Contributor III

Thanks, but actually i was investigating whether i can use VBA UDF's in general - not this specific function.

If this setting cannot be activated by a macro, then it is basically useless in environments where target audience is less tech savvy.

AFAIK these user-settings will be kept within the settings.ini from the user - C:\Users\username\AppData\Roaming\QlikTech\QlikView - and this could be in general changed with administrative measures maybe within a start-script when the user is login into its machine - not a very convenient way but a possibility.

Beside them a quite wide range of UDF's could be implemented with variables - maybe these hints are useful for you:

Variable That Acts Like a User-Defined Function.

Dynamic Field Expressions with Variables

Variables with Parameters

- Marcus

Version history
Revision #:
1 of 1
Last update:
‎08-29-2013 04:23 AM
Updated by: