Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I just started learning/using QlikView.
I built my first App, using data which I extracted directly from the database.
My problem is : a lot of the data-fields contain "garbage".
For example, the "lastname" field contains stuff like : "----", or "*?)=", etc
The point is : some of the fields are either empty, or they contain rubbish data. (Some of the data under "lastname" are even written as "373733".
Obviously, some people couldn't be bothered to spell-out their full names
Nothing wrong with that, sure.
But, I want my List-Boxes to display only those data which are actually DATA.
I already found the solution to removing "empty" data-rows, by using the following expression in my List-Box (for last name)
if (Len(lastname) > 0, lastname)
But, how do I get rid of those other unwanted data?
I tried to solve the problem directly from the SQL Script (under "Main" -- Edit Script). For example, to remove those "lastnames" which contain simple dashes ( - ), I wrote an SQL query, like the following :
Select * from my_table where lastname NOT LIKE '%-%';
But, this is not working. No idea why.
Any way, it's much easier to simply write an expression directly inside the ListBox itself.
But, no idea what format the expression should take.
Thanks
Hi
Try like this
Load *, purgechar(FieldName, '*?)=-') as FieldName
from datasource;
or U can try with KeepChar() function also.
Hi
Try like this
Load *, purgechar(FieldName, '*?)=-') as FieldName
from datasource;
or U can try with KeepChar() function also.
Thanks, Mayil.
I assume that function should be inserted into the Main Script?
Or, inside the List-Box (as an expression) ?
hi
PurgeChar() function can able to use both in front end and script.
Suggestion:
You can creat a new field without unwanted characters and use in list box.
I tried this in the Main Script :
Load *, purgechar(lastName, '*?)=-') as lastName_Clean;
But, it did not create the new field : lastName_Clean.
So, I created a new field, in a new ListBox, and used this :
=purgechar(lastName, '*?)=-') as lastName
The expression was filled with errors.
So I removed the "as", and replaced it with a comma. Still errors
So I simply used this : purgechar(lastName, '*?)=-')
But, there was no effect. Still getting those garbage data
HI
Can you please provide the sample data?
Here is an example of what my LasName field looks like (I selected the top 30 values)
|
' |
- |
'' |
-- |
--- |
---- |
----- |
------ |
------- |
-------- |
--------- |
---------- |
----------- |
------------ |
------------- |
-------------- |
--------------- |
---------------- |
----------------- |
------------------ |
------------------- |
-------------------- |
--------------------------------- |
''-... |
-* |
-. |
-.--- |
-.. |
-§ |
-§- |
-a |
-aaa |
-aaaaa |
-antthony |
-Barbro |
Hi
and a copy of your script
Chris
Mayil : it worked now
purgechar(lastName, '*?)=-') as lastName_Clean;
No idea why it didn't work earlier;
But, I got rid of all the garbage characters!
Thanks !!!
I have a question though : what can i add to the "purgechar" function, to remove NUMBERS as well?
purgechar(lastName, '*?)=-0123456789') as lastName_Clean;