Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Talk to Experts, a LIVE Q&A Webinar. Bring your Qlik Sense Business questions on Aug. 4th. Register
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
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
Highlighted
MVP & Luminary
MVP & Luminary

Re: How to set values to empty values in script?

I think you could use:

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

- Marcus

View solution in original post

3 Replies
Highlighted
MVP & Luminary
MVP & Luminary

Re: How to set values to empty values in script?

I think you could use:

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

- Marcus

View solution in original post

Highlighted
Contributor III
Contributor III

Re: How to set values to empty values in script?

Hi Marcus,

Thank you

Could you please describe what len and trim does?

Just so I understand what I have done 😉

Regards

Nina

Highlighted
MVP & Luminary
MVP & Luminary

Re: How to set values to empty values in script?

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