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

Announcements
ALERT: QlikView server communication interruptions following Microsoft Windows Domain Controller security updates
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Merge update Resident tables

Hello,

Is there any way I could combine three qvds in to a single table?

My first table stores 2009_Sales, Second 2010_Sales and thrid 2011_sales

I want to create a Single table  with all three year sales reported as seperate column with out the account being duplicated

ex. if Account A077 is present in 2009_sales and 2011_sales (not in 2010_sales) I need to create only one record with 2009 & 2011 sales and then put 0 for 2010 . Also I would like to add two columns 1.100_SALE (If there a $100 sale in any of the year value would be Y) and 2.Total (2009_sales+2010_Sales+2011_sales)

Thanks in advance,

A.Paul

2009_SALES_TABLE
AccountContact2009Sales
A001Bill$100
A002Mark$70
A003Steve$25
A004Susie$175
A005James$560

2010_SALES_TABLE
AccountContact2010Sales
A001Bill$230
A002Mark$590
A003Steve$80
A008Jodi$100
A009Job$100
A010Ronnie$20
2011_SALES_TABLE
AccountContact2011Sales
A001Bill$40
A002Mark$200
A009Job$100
A006Elvis$10
A007Mary$5
A004Susie$200

Final_TABLE
AccountContact100_SALE2009Sales2010Sales2011SalesToatlSales
A001BillY$100$230$40$370
A002MarkY$70$590$200$860
A003SteveN$25$80$0$105
A004SusieY$175$0$200$375
A005JamesY$560$0$0$560
A006ElvisN$0$0$10$10
A007MaryN$0$0$5$5
A008JodiY$0$100$0$100
A009JobY$0$100$100$200
A010RonnieN$0$20$0$20
Labels (1)
13 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Anand

Your solution will lose any account/contact combinations that do not exist in all three years, such as James Elvis and Mary because you are using inner joins.

In this sort of case, it is better to create a master table of the keys and then left join into that table, which ensures that no account/contact combinations get lost.

Jonathan

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

Jonathan,

Looks like it did load all 10 accounts.

Thanks,

Jonathan Dienst wrote:

Anand

Your solution will lose any account/contact combinations that do not exist in all three years, such as James Elvis and Mary because you are using inner joins.

In this sort of case, it is better to create a master table of the keys and then left join into that table, which ensures that no account/contact combinations get lost.

Jonathan


Here is what in my final script

TEMP_TAB:

LOAD Account,
Contact,
[2009Sales]
FROM
[\\010 QV\REF\Concat_Data.xls]
(
biff, embedded labels, table is [2009$]);

Join(TEMP_TAB)
LOAD Account,
Contact,
[2010Sales]
FROM
[\\010 QV\REF\Concat_Data.xls]
(
biff, embedded labels, table is [2010$]);

Join(TEMP_TAB)
LOAD Account,
Contact,
[2011Sales]
FROM
[\\010 QV\REF\Concat_Data.xls]
(
biff, embedded labels, table is [2011$]);


Final_Tab:
load *,
(
if(isnull([2009Sales]),0,[2009Sales])+if(isnull([2010Sales]),0,[2010Sales])+if(isnull([2011Sales]),0,[2011Sales])) as TOTAL,
if(([2009Sales]>=100 OR [2010Sales]=100 OR [2011Sales]=100), 'Y', 'N') as [100_SALE]
RESIDENT TEMP_TAB;

DROP TABLE TEMP_TAB;

jonathandienst
Partner - Champion III
Partner - Champion III

Oops, my mistake. An unqualified join is an outer join - I thought that it was an inner join.

Jonathan

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

Jonathan Dienst wrote:

Oops, my mistake. An unqualified join is an outer join - I thought that it was an inner join.

Jonathan

I am very new to QlikView and truly appreciate all the help you folks provide.