Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Subquery on a Script

Hello Experts,

Is it possible create a subquery like this example?

I need aggregate data of two or more tables. Tks



create table Test

from ( table1:

load column1, column2

from Text_file1;

add load column1, column2

from textfile2)

1 Solution

Accepted Solutions
stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi there,

You do not need to be concatenating or joining the tables at all in the load script. In fact you need to be sure that you don't. The two tables should be loaded separately and will be joined in the data model by virtue of the fact that the field Client exists in both tables.

Check the table viewer after a reload to check that this is happening.

Once the data is in create a chart with a dimension of Client and two expressions SUM(Sale) and SUM(Budget). You can select to show your chart as a 'Straight Table'. This should give you the results that you are after.

If you add the values in a Table Box then the numbers will not be aggregated and you will get the scenario where you see the two separate values for Sale and the value for Budget shown twice. It is rare that you will ever want to put a numeric value in a Table Box - it is almost always preferable to use a Chart with a Chart Type of straight table.

I can post up an example of this working if you require.

Regards,
Steve

View solution in original post

14 Replies
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Alexandre,

Two QlikView LOAD statements will do just what you need - CONCATENATE or append the data from one table to another. You don't need to use any CREATE TABLE... Here is an example:

Tab3:

load C1, C2 from ...;

load C1, C2 from ...;

While your fields are exactly the same, the Concatenation will happen automatically. If the fields are slightly different, use prefix CONCATENATE for your subsequent loads.

good luck,

Not applicable
Author

Ok,

But how Do I do to aggregate this data on other table?

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

HI Alexandre,

Once the tables are loaded and concatenated as Oleg describes any expressions you write in a chart will aggregate data across both of the source tables.

If you wish to aggregate the data on the way in then you can use SUM statements in the load script and do a LOAD DISTINCT or GROUP BY. The syntax for GROUP BY needs to be precise - so it is worth referring to the help file.

Hope that helps,

Regards,
Steve

Not applicable
Author

But I have two loads in a same table firt Day-1 and after Day each one houer, and I need the data keep aggregated by customer by example.

on a first load

Client |sale

AAAA |50000

after the second Load

Client |sale

AAAA |50000

AAAA |30000

The problem is I have other table BUDGET with:

Client | Budget

AAAAA | 900000

When QlikView make the relationship the data keep Worng

Client | Sale | Budget

AAAA | 50000 |900000

AAAA | 30000 |900000

And my Budget keeps Duplicated

You Got me?

Not applicable
Author

Actually is not duplicated.....just show two times because has a two reference!!!

Not applicable
Author

Ok but my dinamic table show me

Client | Sale | Budget

AAAA | 80000 | 1800000

And the correct must be

Client | Sale | Budget

AAAA | 80000 | 900000

But for this I have to aggreg my data in LOAD time By Client

Right?

Not applicable
Author

Why did you load two times?Is the same table right? (on a first load Client |sale AAAA |50000 after the second Load Client |sale AAAA |50000 AAAA |30000)

You need put all sales on the same table.....and in another table you put a budget.....and two tables must has a Client like a key??

Did you do that?

Not applicable
Author

My data are refreshed every 15 minutes, so I do 2 Loads the first with month data and the refresh is only daily datas.

I have other table with budget. like you sad with clint like Key

Not applicable
Author

Fisrt you put on QVD.....and second you concatenate with QVD on the same table?