Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
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
tresesco
MVP
MVP

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

View solution in original post

6 Replies
tresesco
MVP
MVP

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

MayilVahanan

Hi

Additional to Tresesco reply:

In script u can use like this'

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

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

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.

tresesco
MVP
MVP

Could you post a sample qvw that demonstrates the issue?

Not applicable
Author

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

Not applicable
Author

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