Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Expression will not work script side

Hi,

I have an expression that works fine in a table box or chart and i want to use this script side.

The reason I need it script side is I want to create a new field with a flag in it.

if(max(len(keepchar(lower([Telephone Number]), '- ! # $ % ( ) , * . : ; ? @ [ ] { } | ~ < > = £ / \ & "'))) > 0, 1, 0)

Basically the expression checks the telephone number field to see if there are any characters in there that should not be.

Any thoughts are appreciated !

Thanks

Stuart

1 Solution

Accepted Solutions
MVP
MVP

Re: Expression will not work script side

If you use max() which is an aggregation function you have to use 'Group By' clause as well in the script.

Otherwise, using FindOneOf() would possibly be a better choice, like:

if(FindOneOf([Telephone Number]), '- ! # $ % ( ) , * . : ; ? @ [ ] { } | ~ < > = £ / \ & "') > 0, 1, 0) as Flag

6 Replies
MVP
MVP

Re: Expression will not work script side

If you use max() which is an aggregation function you have to use 'Group By' clause as well in the script.

Otherwise, using FindOneOf() would possibly be a better choice, like:

if(FindOneOf([Telephone Number]), '- ! # $ % ( ) , * . : ; ? @ [ ] { } | ~ < > = £ / \ & "') > 0, 1, 0) as Flag

Re: Expression will not work script side

Hi

Additional to Tresesco reply:

In script u can use like this'

if(len(keepchar(lower([Telephone Number]), '- ! # $ % ( ) , * . : ; ? @ [ ] { } | ~ < > = £ / \ & "')) > 0, 1, 0) as flag

Not applicable

Re: Expression will not work script side

Thanks for the response.

I tried to use FindOneOf and a strange thing happens. On the Design side it works fine as an Expression. On the script side it is flagging some fields that do not have issues. Side by side in a Pivot chart I can see the strange anomaly.

MVP
MVP

Re: Expression will not work script side

Could you post a sample qvw that demonstrates the issue?

Not applicable

Re: Expression will not work script side

App contains sensitive info. Will try and make a small app with the same issue but with fake data

Not applicable

Re: Expression will not work script side

Actualy on detailed investigation its something to do with the data in that field auto purging spaces. So I think your expression works fine its another issue.

thanks very much

Stuart

Community Browser