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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

match records and create flag


Hi all,

I have two tables like...

                                                                 

MasterAccount
Account1
Account2
Account3
Account4
Account5
Account6
Account7
Account8
Account9
Account10
Account11
Account12
Account13
Account14
Account15
Account16
Account17
Account18
Account19
Account20

and other table

                       

WebAccount
Account4
Account8
Account11
Account2
Account18
Account19
Account20

in script side I want something below, if account has match then create flag in master table like below.

                                                                                      

MasterAccountFlag
Account10
Account21
Account30
Account41
Account50
Account60
Account70
Account81
Account90
Account100
Account111
Account120
Account130
Account140
Account150
Account160
Account170
Account181
Account191
Account201

Thanks

Vinay

I FORGOT TO TELL YOU THAT IN MASTER TABLE ACCOUNT ARE REPAETED LIKE WE MIGHT GET MULTIPLE TIME SAME ACCOUNTS.

1 Solution

Accepted Solutions
MK_QSL
MVP
MVP

MA:

Load * Inline

[

MasterAccount

Account1

Account2

Account3

Account4

Account5

Account6

Account7

Account8

Account9

Account10

Account11

Account12

Account13

Account14

Account15

Account16

Account17

Account18

Account19

Account20

];

NoConcatenate

WA:

Load * Inline

[

WebAccount

Account4

Account8

Account11

Account2

Account18

Account19

Account20

];

NoConcatenate

FINAL:

Load *, '1' as Flag

Resident MA

Where Exists (WebAccount,MasterAccount) ;

Load *, '0' as Flag

Resident MA Where NOT Exists (WebAccount,MasterAccount);

Drop Table MA;

====================

Now Create a Straight Table with MasterAccount as Dimension and Flag as an expression

Go to presentation tab and untick Suppress Zero - Values

View solution in original post

6 Replies
its_anandrjs
Champion III
Champion III

Hi,

Load some thing like below

Account:

load * Inline

[

MasterAccount

Account1

Account2

Account3

Account4

Account5

Account6

Account7

Account8

Account9

Account10

Account11

Account12

Account13

Account14

Account15

Account16

Account17

Account18

Account19

Account20

];

Concatenate

WAccount:

LOAD WebAccount as MasterAccount;

load * Inline

[

WebAccount

Account4

Account8

Account11

Account2

Account18

Account19

Account20

];

LOAD *,

if(Count(MasterAccount) > 1 ,1,0) as flag

Resident Account

Group by MasterAccount;

Thanks & Regards

MK_QSL
MVP
MVP

MA:

Load * Inline

[

MasterAccount

Account1

Account2

Account3

Account4

Account5

Account6

Account7

Account8

Account9

Account10

Account11

Account12

Account13

Account14

Account15

Account16

Account17

Account18

Account19

Account20

];

NoConcatenate

WA:

Load * Inline

[

WebAccount

Account4

Account8

Account11

Account2

Account18

Account19

Account20

];

NoConcatenate

FINAL:

Load *, '1' as Flag

Resident MA

Where Exists (WebAccount,MasterAccount) ;

Load *, '0' as Flag

Resident MA Where NOT Exists (WebAccount,MasterAccount);

Drop Table MA;

====================

Now Create a Straight Table with MasterAccount as Dimension and Flag as an expression

Go to presentation tab and untick Suppress Zero - Values

Not applicable
Author

Its working perfect.

Thanks

Vinay

MK_QSL
MVP
MVP

Below is the Better Approach...

MA:

Load * Inline

[

MasterAccount

Account1

Account2

Account3

Account4

Account5

Account6

Account7

Account8

Account9

Account10

Account11

Account12

Account13

Account14

Account15

Account16

Account17

Account18

Account19

Account20

];

NoConcatenate

WA:

Load *, WebAccount as MasterAccount Inline

[

WebAccount

Account4

Account8

Account11

Account2

Account18

Account19

Account20

];

NoConcatenate

FINAL:

Load *, '1' as Flag

Resident MA

Where Exists (WebAccount,MasterAccount) ;

Load *, '0' as Flag

Resident MA Where NOT Exists (WebAccount,MasterAccount);

Drop Table MA;

er_mohit
Master II
Master II

see the attached file

its_anandrjs
Champion III
Champion III

Hi,

One of the another simple way and in this you keep both the tables MasterAccount & WebAccount sepearate and do calculation in another table

Account:

load * Inline

[

MasterAccount

Account1

Account2

Account3

Account4

Account5

Account6

Account7

Account8

Account9

Account10

Account11

Account12

Account13

Account14

Account15

Account16

Account17

Account18

Account19

Account20

];

NoConcatenate

WebAccount:

load * Inline

[

WebAccount

Account4

Account8

Account11

Account2

Account18

Account19

Account20

];

NoConcatenate

Temp:

LOAD

MasterAccount as MKey Resident Account;

Concatenate

LOAD WebAccount as MKey Resident WebAccount;

NewData:

LOAD *,

if(Count(MKey) > 1 ,1,0) as Flag

Resident Temp

Group by MKey;

DROP Table Temp;

EXIT Script;

Hope this helps

Thanks & Regards