Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Priyanka1902
Contributor II
Contributor II

Left Join in Qlik

Hi,

I have 2 tables:

Project Number Hours
A745 100
B675 200

 

Project Number Sub Project Number
A745 A745001
A745 A745002
B675 B675001

 

I am using Left Join to join table 2 with Table 1. After reload when I do the Sum(Hours), it shows values 400 bcz it is adding 100, 2 times. is there any way where I will get 300 which is correct. Please help.

Labels (5)
4 Replies
TauseefKhan
Creator III
Creator III

Hi @Priyanka1902,

Use: Sum(distinct(Hours))

hic
Former Employee
Former Employee

Don't join. If you keep it in two tables you will have a correct data model, and the Qlik engine will do what you want.

Vegar
MVP
MVP

As HIC is saying, don't join. Keep the two tables as they are. The data will be associated with each other through their common field name, but not duplicated as you experience with the join.

The reason you get 400 when joining is that your join on Project number will  make both the Sub Project Numbers of A745 get the 100 hours value on their row. Therfore S745 will sum up to 200 hours and not 100 hours. This problem will be avoided with HICs suggestion.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I agree with @hic suggestion. I might also ask why there are duplicate rows in Table 2? Are they needed? It might be appropriate to add the DISTINCT keyword when loading Table 2 to avoid the duplicates. 

-Rob