Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
davyqliks
Specialist
Specialist

do not load if null in load statement

I have the following code:

 

Load
if(Len(Trim("FIBRE 1") > 0 ) and "PERCENT 1" = '100' and wildmatch(trim("FIBRE 1"),
'Viscose LENZING™ ECOVERO™' ),
'ViscoseLENZINGECOVERO100',"FIBRE 1") as ViscoseLENZINGECOVERO100,
From......

This creates a field called  ViscoseLENZINGECOVERO100 where the Fibre 1 = 'Viscose LENZING™ ECOVERO™'  and Percent 1 =100

 

I also have Dimensions FIBRE 2 and FIBRE 3 and i need to add another level to the above to include

if FIBRE2 <0 or =0 (blank)

 

The end result should be load where fibre 1 = 'Viscose LENZING™ ECOVERO™'  and Percent 1 =100 and fibre 2 and fibre 3 blank

 

PLease can someone help to try and include this.

I have tried numerous ways but then lose the values which are ViscoseLENZINGECOVERO100

 

thank you in advance

Labels (4)
1 Solution

Accepted Solutions
ArnadoSandoval
Specialist II
Specialist II

Hi @davyqliks 

This seems to work, the code below is the script I wrote to load some sample data with the information you shared.

Table:
Load *,
     if(Len(Trim("FIBRE1") > 0 ) and 
        "PERCENT1" = '100'       and 
        wildmatch(trim("FIBRE1"), 'Viscose LENZING ECOVERO' )  and
        Len(Trim("FIBRE2")) = 0 and 
        Len(Trim("FIBRE3")) = 0,
    'ViscoseLENZINGECOVERO100',
    "FIBRE1") as Result, // ViscoseLENZINGECOVERO100
    Len(Trim("FIBRE2")) As Len_Fibre2,
    Len(Trim("FIBRE3")) As Len_Fibre3
Inline [
Rec, FIBRE1, FIBRE2, FIBRE3, PERCENT1
1, Viscose LENZING ECOVERO, , , 100
2, Viscose LENZING ECOVERO, 1, , 100
3, Viscose LENZING ECOVERO, 1, 1, 100
4, Viscose LENZING ECOVERO,  , 1, 100
5, Whatever, , , 100
6, Whatever, 1, , 100
7, Whatever, 1, 1, 100
8, Whatever, , 1, 100
];

I got rid of the TM character for my local test, the screenshot shows my results:

Donot_load_if_null-01.png

Hope this helps,

Arnaldo Sandoval
A journey of a thousand miles begins with a single step.

View solution in original post

2 Replies
ArnadoSandoval
Specialist II
Specialist II

Hi @davyqliks 

This seems to work, the code below is the script I wrote to load some sample data with the information you shared.

Table:
Load *,
     if(Len(Trim("FIBRE1") > 0 ) and 
        "PERCENT1" = '100'       and 
        wildmatch(trim("FIBRE1"), 'Viscose LENZING ECOVERO' )  and
        Len(Trim("FIBRE2")) = 0 and 
        Len(Trim("FIBRE3")) = 0,
    'ViscoseLENZINGECOVERO100',
    "FIBRE1") as Result, // ViscoseLENZINGECOVERO100
    Len(Trim("FIBRE2")) As Len_Fibre2,
    Len(Trim("FIBRE3")) As Len_Fibre3
Inline [
Rec, FIBRE1, FIBRE2, FIBRE3, PERCENT1
1, Viscose LENZING ECOVERO, , , 100
2, Viscose LENZING ECOVERO, 1, , 100
3, Viscose LENZING ECOVERO, 1, 1, 100
4, Viscose LENZING ECOVERO,  , 1, 100
5, Whatever, , , 100
6, Whatever, 1, , 100
7, Whatever, 1, 1, 100
8, Whatever, , 1, 100
];

I got rid of the TM character for my local test, the screenshot shows my results:

Donot_load_if_null-01.png

Hope this helps,

Arnaldo Sandoval
A journey of a thousand miles begins with a single step.
davyqliks
Specialist
Specialist
Author

Apologies for my delay in reply,

Thank you so much, this works well for me. Really appreciate you help.

 

DQ