Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
kalavala_vijayk
Contributor II
Contributor II

How to compare multiple columns from 2 different sources

Hi Qlik experts,

I would like to compare diff. columns from diff. sources. same like how we do in excel with pivots.

Source- 1

Employee IDNameOrganisationRole
1001ABCSalesManager
1002BCDMarketingAssociate
1003CDEOperationsSr. Manager
1004DEFOperationsAssociate

 

Source-2

Employee IDNameOrganisationRole
1001ABCSalesManager
1002BCDMarketingAssociate
1003CDEOperationsSr. Manager
1005DEFMarketingDirector

 

Output in Qlik

DescriptionSource-1Source-2Difference
Sales110
Marketing121
Operations21-1
    

 

So that i can compare if migration is correct.

 

Thanks for your suggestions.

Labels (1)
1 Solution

Accepted Solutions
Kushal_Chawda

@kalavala_vijayk  if field names are same in both sources then you could try below, otherwise you need to rename it to make sure that names are matching in both sources

Data:
LOAD *,
     'Source 1' as Source
FROM Source1;

concatenate(Data)
LOAD *,
     'Source 2' as Source
FROM Source2;

 

Now, create a table with below Dimension & Measure

Dimension:

Organization

Measure:

1) =Count({<Source={'Source 1'}>}Organisation)    // Source 1

2) =Count({<Source={'Source 2'}>}Organisation)    // Source 2

3) =Count({<Source={'Source 2'}>}Organisation)-Count({<Source={'Source 1'}>}Organisation) // Difference

View solution in original post

4 Replies
Kushal_Chawda

@kalavala_vijayk  why Marketing is repeated in your Output?

chinmayadash07
Contributor II
Contributor II

Yes You can do the same, Please do the follow steps.

Data:

load * ,Source 1 as Flag  from Source 1;

concatenate

load * ,Source 2 as Flag  from Source 2;

then create a pivot table in qliksense and take organisation as dimesnion and Flag as column and create measure (count(organisation))

and then create an another measure called difference where u can write =count(organisation) - before(count(organisation),1) measure to achieve the same

Else you can write the same calculation in script also

kalavala_vijayk
Contributor II
Contributor II
Author

@Kushal_Chawda  - Thanks , i have corrected.

Kushal_Chawda

@kalavala_vijayk  if field names are same in both sources then you could try below, otherwise you need to rename it to make sure that names are matching in both sources

Data:
LOAD *,
     'Source 1' as Source
FROM Source1;

concatenate(Data)
LOAD *,
     'Source 2' as Source
FROM Source2;

 

Now, create a table with below Dimension & Measure

Dimension:

Organization

Measure:

1) =Count({<Source={'Source 1'}>}Organisation)    // Source 1

2) =Count({<Source={'Source 2'}>}Organisation)    // Source 2

3) =Count({<Source={'Source 2'}>}Organisation)-Count({<Source={'Source 1'}>}Organisation) // Difference