Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
nina_jensen
Contributor III
Contributor III

How to set values to empty values in script?

Hi Community!

In the load script I want to set values to a field that in the qvd file has no value. This is so I can load only these fields, and furthermore, use them in calculations.

My database is a qvd file.

Example:

Lets say this qvd file contains the columns Store - Item - Customer - Broken like in the table below.

If the item is broken the value in the field Broken is set to B.

If the item is not broken, the field is empty.

When I load the script the missing value in these empty fields is shown like a hyphen -  (since its empty)

In the database which is the basis for the qvd file, this fields are only filled if the item is Broken.

The B field records is not necessary to load as I am only interested in loading the records for the empty field values.

The empty field values should be given a string, e.g U (for Unbroken) in the script. This applies to all empty fields in that column.

StoreItemCustomerBroken
ABC StoreWork BagMickey Mouse-
DEF StoreHandbagDolly DuckB
ABC StoreHandbagDonald Duck-
GHI StoreSuitcasePluto-
GHI StoreWork BagMickey MouseB
1 Solution

Accepted Solutions
marcus_sommer

I think you could use:

if(len(trim(Broken))=0, 'ok.', Broken) as broken

- Marcus

View solution in original post

3 Replies
marcus_sommer

I think you could use:

if(len(trim(Broken))=0, 'ok.', Broken) as broken

- Marcus

nina_jensen
Contributor III
Contributor III
Author

Hi Marcus,

Thank you

Could you please describe what len and trim does?

Just so I understand what I have done 😉

Regards

Nina

marcus_sommer

Len() counts the number of chars within a fieldvalue and trim() removed possible leading and ending spaces and it's combination it's similar to isnull() but it extend the logic to fieldvalues like '' or ' ' which are strictly spoken not NULL but contain not a real respectively useful value.

- Marcus