Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

Best way to calculate a new field

I have two .qvw : GetData.qvw (load data from SQL DB creating qvd) and ShowData.qvw (load data from qvd and prepare data to be presented).

In the SQL DB there are two tables that I import creating two distinct qvd(s): table1.qvd and table2.qvd.

In the ShowData.qvw I have to load the two qvd(s)

Table1:

(

Key,

A,

)

Table2:

(

Key,

B,

….

)

In the ShowData.qvw I would have a calculated field C = A-B, for all the rows in Table1 (left join).

I did as follow:

Table:

LOAD

Key,

A,

From table1.qvd;

Left join

LOAD

Key,

B,

….

From table2.qvd;

NewTable:

LOAD *

C=A-B

Resident Table;

And it works, but I'm not sure that this is the best way to do it as it requires loading the data a second time in order to do the calculation.

Can someone help?

Many Thanks

2 Replies
MVP
MVP

Re: Best way to calculate a new field

Here is an alternative approach:

MAP:

MAPPING LOAD

Key,

B

From table2.qvd;

Table:

LOAD

Key,

A,

A - applymap('MAP',Key) as C

From table1.qvd;

Not applicable

Re: Best way to calculate a new field

Thanks for the suggestion, the problem is that tables have more than two fields. If I understood well how the map works, I can'use it as Tables1 and Tables2 have more fields.

Many Thanks, Martina