Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Create a table with data from another table

Hello dear community, I have the following question that I hope you can help me with:

I have the following data about products and seller's ID, on which I'm only interested in the first 10.

 

ProductPriceQuantitySeller ID
1Computer1015001
2Banana1014002
3Apple1013003
4Phone1012004
5Cell Phone1011005
6Mouse1010006
7Keyboard109007
8HeadPhone108008
9Screen107009
10Printer1060010
11Scanner1050011
12Pen1040012
13Tablet1030013
14Smartphone1020014
15FlashDrive1010015

When I apply a change in the sales policies, the sales also have been modified::

 

ProductPriceQuantitySeller ID
1Computer1015001
2FlashDrive10140015
3Smartphone10130014
4Tablet10120013
5Cell Phone1011005
6Mouse1010006
7Keyboard109007
8HeadPhone108008
9Screen107009
10Printer1060010
11Scanner1050011
12Pen1040012
13Phone103004
14Apple102003
15Banana10100

2

As you can see, with the sales policies changes, the Seller's ID 15,14 and 13 were highly benefited.

What i want to do, is that in another table, just put the data of the sellers that in the first table were under the first 10, and in the second table (with the policies changes) are above the first 10 (15, 14 and 13):

 

ProductPriceQuantitySeller ID
2FlashDrive10140015
3Smartphone10130014
4Tablet10120013

Is there anyway that this can be done?

Thanks a lot!

6 Replies
maxgro
MVP
MVP

T1:

LOAD N°,

     Product,

     Price,

     Quantity,

     [Seller ID]

FROM

[https://community.qlik.com/thread/175069]

(html, codepage is 1252, embedded labels, table is @1);

T2:

NoConcatenate

LOAD N°,

     Product,

     Price,

     Quantity,

     [Seller ID]

FROM

[https://community.qlik.com/thread/175069]

(html, codepage is 1252, embedded labels, table is @2);

Tmp:

load [Seller ID] as SellerGT10 Resident T1 where N° > 10;

Result:

NoConcatenate

load * Resident T2 where N° <= 10 and exists (SellerGT10, [Seller ID]);

DROP Table Tmp;

DROP Table T1, T2;

1.png

Anonymous
Not applicable
Author

Hello Massimo, thanks for the answer, but I still have a question though:
I have another problem, in another set of data  that  I have, I don't have the "N°" column, but I need to arrange the top 10 sellers using the "quantity" column. How can I do that?

Thx

puttemans
Specialist
Specialist

Hi,

You load the table descending based upon quantity, and you add an autonumber(). As of there, you do have the No column

Anonymous
Not applicable
Author

Just like that? I put the autonumber() and it takes automaticly the quantity as the right parameter?

puttemans
Specialist
Specialist

Attention, you need to define the parameter by which you want to load/order. For example:

LOAD

     Product,

     Price,

     Quantity,

     [Seller ID],

    Autonumber () as Nr

FROM table x

Order by Quantity desc;

maxgro
MVP
MVP

if I understand you can resident load the data order by quantity or quantity desc and add a counter; then you can use the counter to filter the first 10, etc, ..... (bold). I just did for one of the table, T1, you can expand to T2.

T1:

LOAD N°,

     Product,

     Price,

     Quantity,

     [Seller ID]

FROM

[https://community.qlik.com/thread/175069]

(html, codepage is 1252, embedded labels, table is @1);

T2:

NoConcatenate

LOAD N°,

     Product,

     Price,

     Quantity,

     [Seller ID]

FROM

[https://community.qlik.com/thread/175069]

(html, codepage is 1252, embedded labels, table is @2);

Tmp2:

load rowno() as rowno, [Seller ID] as SellerGT10, Quantity Resident T1

order by Quantity desc;

Tmp:

NoConcatenate load * resident Tmp2 where rowno > 10;

drop table Tmp2;

Result:

NoConcatenate

load * Resident T2 where N° <= 10 and exists (SellerGT10, [Seller ID]);

DROP Table Tmp;

DROP Table T1, T2;