Skip to main content
Announcements
See why Qlik was named a Leader in the 2024 Gartner® Magic Quadrant™ for Data Integration Tools for the ninth year in a row: Get the report
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

in which scenario keep is using?

Hi

I am new to qlikview

In which scenario we have to use keep().

tell me in simple word...

why keep()?

thanks in advance

Venu

1 Solution

Accepted Solutions
sundarakumar
Specialist II
Specialist II

PFA.

Keep is used in cases like

u have first loaded a table with id and region

id     region

1          n

2          e

3          w

now u have another table where u have id and sales

id     sales

1          100

2          200

u dont want the data that dont have sales (3,w) bec it is useless without sales data,

now what u do is

one:

load * table1;

two:

right keep

load * table2;

this will work as

keep the values in table 1(if they are present in table 2)....

left keep would do the reverse which is not applicable in this case

Please go through attachment to get more clear...

i have used all types of keep and joins

Hope this helps

-Sundar

View solution in original post

3 Replies
veeranj
Creator II
Creator II

Hi Venu,

diff between join and keep is that :

if u mention JOIN condition between two tables and resultantly u can view only one table in Qlikview DataMOdel but

where as for KEEP it will keep both the tables in the  Qlikview DataMOdel .

and the way how JOIN and KEEP works is same.

it will give same output.

Press CTRL+T to view the datamodel in the Qlikview

Anjee

qv_jagan
Partner - Creator
Partner - Creator

Hi Venu,

For Example let us consider 2 tables.

Scenario 1:

Table A:

Country     Sales

Aus          100

Ind            200

UAE         300

Table B:

CountryCode    Country

215                 Aus

91                  Ind

02                  UAE

In this scenario both Keep and Join can be used.

Join and Keep can be used when there are no duplicates in the dimension (Table B) tables

Scenario 2:

Table A:

Country     Sales

Aus          100

Ind            200

UAE         300

Table B:

RegionName    Country

Sydney            Aus

Melbourne        Aus

TamilNadu       Ind          

AbuDhabi        UAE

In this case only Keep should be used since Dimension table is duplicated.

When Keep is used  --- Correct

Sum(Sales): 100 when selecting Aus. 

Sum(Sales): 100 when selecting Sydney.

Sum(Sales): 100 when selecting Melbourne.

When Join is used -- Wrong

Sum(Sales): 200 when selecting Aus.

Sum(Sales): 100 when selecting Sydney.

Sum(Sales): 100 when selecting Melbourne.

sundarakumar
Specialist II
Specialist II

PFA.

Keep is used in cases like

u have first loaded a table with id and region

id     region

1          n

2          e

3          w

now u have another table where u have id and sales

id     sales

1          100

2          200

u dont want the data that dont have sales (3,w) bec it is useless without sales data,

now what u do is

one:

load * table1;

two:

right keep

load * table2;

this will work as

keep the values in table 1(if they are present in table 2)....

left keep would do the reverse which is not applicable in this case

Please go through attachment to get more clear...

i have used all types of keep and joins

Hope this helps

-Sundar