Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

I want to know internal process of below.

Hi Experts,

I want to know internal process of below Script.

Tab:

Load * Inline

[KeyName,Salary

A,10

B,20

A,10

B,30];

Tab1:

Load distinct KeyName

    ,'' as Salary

   

Resident Tab;

And my result is :

KeyName Salary
A Null
A10
B Null
B20
B30

With out distinct:

Tab:

Load * Inline

[KeyName,Salary

A,10

B,20

A,10

B,30];

Tab1:

Load KeyName

    ,'' as Salary

   

Resident Tab;

And the result is:

KeyName Salary
A10
A10
B20
B30
ANull
ANull
BNull
BNull

Wat is difference between this two?

Thanks in advance

Regards,

Kabilan K.

9 Replies
sundarakumar
Specialist II
Specialist II

Hi Kabilan,

What happening is

1. plese note the table that u have defined as inline and the secend one you load as resident autoconcat as they have same fields, try using noconcatenate before loading the second table it will result in 2 tables.

with distinct

what u have defined in inline a10 a10 b20 b30

u have 3 unique entries a10,b20,c30 and this is appended with the second table a-null and b -null since u have given distinct key its takein only one  a and one b.

2. without distinct

it is showing 4 values for a and 4 values for b.

2  in first table , 2 b in first table

2 a in resident table, 2 b in resident table.

Hope this helps

-Sundar

Not applicable
Author

Yes,

My question is,

why is it take a unique rows(3 row) from first table if we using distinct key word in second table?

and

Why is it take a all rows(4 rows) from first table if we are not using distinct keyword in second table?

Regards,

Kabilan K.

sundarakumar
Specialist II
Specialist II

Plese post the sample app that you have worked above.

Where from are u seeing the result, table viewer or getting the values in some chart or exporting it?

-Sundar

Not applicable
Author

Hi Kabilan,

In the first load, you have A10, B20, B30 as unique values. While taking resident load, only KeyName field is considered which has 2 unique values A and B.

Thus, in 1st scenario(using distinct), you got only 2 NULL records.

A     NULL

B     NULL

In 2nd scenario(without using distinct), you got NULL records as many number of times you have rows in loaded table.

A     NULL

A     NULL

B     NULL

B     NULL

Not applicable
Author

in table viewer.

PFA.

Not applicable
Author

Yes,

In my first scenario, I got only 2 null values because I used distinct, second 4 null values bez I didn't used distinct.

My qus is Y first table returns 3 rows and 4 rows respectively?

Regards,

Kabilan K.

sundarakumar
Specialist II
Specialist II

Hi Kabilan,

When you are trying to load distinct in the second table it will check for distinct value and save all the unique values(unique value combining all the col in the table). You can find all the four values when you are using noautoconcat.

or u can find all the values when including another col called metric.PFA.

This is how distinct works.

we may not face such scenarios while working live as we atleast have some value distinct in all col.

But still it is amazing observation. Thanks...

-Sundar

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

K Kabilan wrote:

My qus is Y first table returns 3 rows and 4 rows respectively?

Because your chart tables contain the union of the two tables, so 4+2 for the distinct example and 4+4 without the distinct.

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Hi jonathan,

No, My script returns 3+2 for the distinct and 4+4 for with out distinct, So that I am asking Y first table returns 3 rows when we use the distinct in second table?

Regards,

Kabilan K./