Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
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
Hi
Additional to Tresesco reply:
In script u can use like this'
if(len(keepchar(lower([Telephone Number]), '- ! # $ % ( ) , * . : ; ? @ [ ] { } | ~ < > = £ / \ & "')) > 0, 1, 0) as flag
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.
Could you post a sample qvw that demonstrates the issue?
App contains sensitive info. Will try and make a small app with the same issue but with fake data
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