Using the Filter Transformation Task to Keep Only Data Starting with: One Letter and Two Numbers
Filtering with a Java Script Expression: Utilizing String Search ( ) + Expression
String Search( ): searches a string for a specified value, and returns the position of the match.
string.search(searchvalue)
where searchvalue is a regular expression. (Required)
A string will automatically be converted to a regular expression.
Client Attempted to Filter with the Following Expression:
var x = $val["ColumnName"];
var m = x.search(/^[A-Z]\d[0-9]{2}/);
input = m;
input
This did not produce any results with this Expression, if he put in a value like L35, it would show the results of those with L35 in the data. Which told me the expression was not quite right.
Why Did The Expression Not Work?
Missing Boundary
\b allows you to carry the match the whole word using a regular expression: \bword\b
Missing Quantifier
While it stated [A-Z], which will return the first occurrence of any capital letter, it did not state how many [A-Z]{1}, which is the {1}.
Combined Two Ways to Create the Expression
While it stated d[0-9]{2} which will not return anything as it combined two different ways to create the expression, either you use d{n} or [0-9]{n} and it will return the first occurrence of any digit. While it had the quantifier the previous part did not have it did not have the correct statement. It was later edited {2-4} as they recalled some rows of information may have up to 4 numbers in them, so it can also be a range of digits.
So once it was adjusted for those issues it worked!
var x = $val["ColumnName"];
var m = x.search(/\b^[A-Z]{1}\d{2-4}\b/);
input = m;
input
For More Information:
- iDashboards Builder Manual 14 Analytics
- iDashboards Data Hub Manual 8. Extract, Transform and Load
- OSKAR: Data Analytics
Disclaimer: iDashboards Technical Support Engineers are not Data Analysts who know in depth SQL Queries or JavaScript Expressions. We often learn these skills on the job and have limited knowledge. We do our best to help you with your software in determining if: you are not leveraging the software in the best way for your data or you found a bug in the software, because we want to assist you in your success. If you have issues with in depth queries or expressions please contact iDashboards Support and know that it will take a bit of time to figure out what is necessary for this issue, and if necessary we will refer you to your Client Success Manager to schedule time with a Principal Product Engineer.
If the above is unable to resolve the issue, then please contact iDashboards Support for further assistance.
Comments
0 comments
Please sign in to leave a comment.