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

Exclude the null value

Hi everyone ,

I have some issue to load a data table without the null value.

Here is an example of datas :

RefCurrency rate 1Currency rate 2
255-1.36-1.52529
255--

What I want is to keep every row with currency rate 1 or currency rate 2 different from NULL, so the first row.

Here is what I did in the set analysis :

test:

LOAD [currency rate 1] as currency_rate_1,

     [currency rate 2] as currency_rate_2,

     ref

FROM

(biff, embedded labels, table is Sheet1$);

test2:

NoConcatenate

load *

resident test

where currency_rate_2 > 0;

But when I create a table box with test2 I have the second row too ...

I tested too :

where isnull(currency_rate_2) = 0;

where len(currency_rate_2) > 0;

Can anyone help me to understand why please ?

Kind regards ,

Gwendaline

1 Solution

Accepted Solutions
sunny_talwar

I think your script is working just fine... look at the data model view here

Capture.PNG

You are seeing the null rows because you still have them in the other two tables.... If you add DROP Table test_vrai, test_vrai2; at the end of the script.... you won't see the nulls anymore

Capture.PNG

View solution in original post

6 Replies
sunny_talwar

I think you need this for testing

test:

LOAD [currency rate 1] as currency_rate_1,

     [currency rate 2] as currency_rate_2,

     ref

FROM

(biff, embedded labels, table is Sheet1$);

test2:

NoConcatenate

LOAD currency_rate_1 as currency_rate_1_TEST,

     currency_rate_2 as currency_rate_2_TEST

Resident test

Where Len(Trim(currency_rate_2)) > 0;

Now check currency_rate_1_TEST and currency_rate_2_TEST

Not applicable
Author

Hi Sunny ,

Thanks a lot for your help.

It works with my example but when I use it with other data it doesn't : there is one variable with null value sometimes and it seems that is the source of my issue.

My data :

 

datevar8refvar14var15var16var17var18var20var21var22currency rate 1currency rate 2var23
11/01/17SGD2.553E+09 300441.44441.443.1E+092021-1.52529 2
11/01/17SGD2.553E+09 300441.44441.443.1E+092021 -1.362

And the script (I have several variables so I write "..." here but in my script there are all variables) :

test_vrai:

LOAD date,

     ...,

     var23,

     [currency rate 1] as currency_rate_1,

     [currency rate 2] as currency_rate_2

FROM

(ooxml, embedded labels, table is Sheet1);

test_vrai2:

NoConcatenate

load date, ...,

     var23,

     max(currency_rate_1) as max_currency_rate_1,

     max(currency_rate_2) as max_currency_rate_2

resident test_vrai

group by date, ... , var23;

test_vrai3:

NoConcatenate

load date, ... , var23,

     max_currency_rate_1 as max_currency_rate_1_test,

     max_currency_rate_2 as max_currency_rate_2_test

resident test_vrai2

where Len(Trim(max_currency_rate_1)) > 0 ;

My result should be only one row but I have 2 rows : 1 correct with max_currency_rate_1_test different from null and max_currency_rate_2_test different from null and 1 row with null values for these 2 indicators.

I think that now the issue is linked to the group by. What do you think ?

To a better understanding : I use a group by because I have 2 rows : one with the currency rate 1 and another with the currency rate 2 and I want only 1 row. The group by works but the "where" doesn't.

Kind regards ,

Gwendaline

sunny_talwar

You might be right.... it might be helpful to look at the output after the group by to see how many rows are available and what are the values.... and proceed from there... if you are able to share a sample qvw to look at... may be we can help better....

Not applicable
Author

You will find my excel file and the qvw.

Hope it will help.

Gwendaline

sunny_talwar

I think your script is working just fine... look at the data model view here

Capture.PNG

You are seeing the null rows because you still have them in the other two tables.... If you add DROP Table test_vrai, test_vrai2; at the end of the script.... you won't see the nulls anymore

Capture.PNG

Not applicable
Author

It works. Thanks a lot Sunny for your help !

Have a nice day,

Gwendaline