Skip to main content
Announcements
Join us on Sept. 17 to hear how our new GenAI Assistant empowers data professionals: REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
random_user_3869
Partner - Creator III
Partner - Creator III

How to replace a value with space string to null

Hello,

 

I have several field from some databases that have the following issue:

there are some field values in my script  with empty values :

-issue qlik.PNG

it's empty cell basically that i want to consider those values as null but if i do let's say if len(Field A) = 0, Null()

it doesn't work because the string value can ba ' ' or '  ' or '     '. BAsically varchar (2) or varchar 40.

Anyone can help me with that.

Thank you

Labels (1)
  • SaaS

1 Solution

Accepted Solutions
chris_djih
Creator III
Creator III

Then i would go with the purgechar() method. You can use Chr(32) as character code for space instead of ' '. Another space-character is chr(160).
So your load statement shoul llook like this:

PurgeChar(PurgeChar([ValueField], chr(32)),chr(160))  as [CleanValue]

There should be no more spaces in the [CleanValue] field

If you found help, mark the correct answer and give some likes to ALL contributors, that tried to help.

View solution in original post

5 Replies
chris_djih
Creator III
Creator III

try trim(FieldA) - this deletes all spaces.

if any other character neds to be deleted use: purgechar(FieldA,'#') to delete every '#' in the FieldA

If you found help, mark the correct answer and give some likes to ALL contributors, that tried to help.
vikasmahajan

Hi,

while loading script check with  [Value A] :

If(IsNull([Value A]) or len([Value A]) =0, Null_value, [Value A]) As [Value A] 

use Null_value in set analysis to filter null values.

 

Reference : 

https://community.qlik.com/t5/QlikView-Documents/NULL-handling-in-QlikView/ta-p/1484472

https://www.johndaniel.com/when-values-arent-values-null-handling-in-qlik/

 

Hope this help.

Vikas

 

 

 

 

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
random_user_3869
Partner - Creator III
Partner - Creator III
Author

The issue is that the space (trim doesnt work) can have a lenght of 20 30 or 40 or more depending on the field value)

So the issue is that i need to make a condition and i don't know how to do it.

Because the field value can be : '' or '   ' or  '   '

chris_djih
Creator III
Creator III

Then i would go with the purgechar() method. You can use Chr(32) as character code for space instead of ' '. Another space-character is chr(160).
So your load statement shoul llook like this:

PurgeChar(PurgeChar([ValueField], chr(32)),chr(160))  as [CleanValue]

There should be no more spaces in the [CleanValue] field

If you found help, mark the correct answer and give some likes to ALL contributors, that tried to help.
random_user_3869
Partner - Creator III
Partner - Creator III
Author

Thank you it worked !!