Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
adamjank
Contributor III
Contributor III

[Left Join / Less Rows] Issue

Hello,

I've experienced very, very strange situation as the SQL experienced employee.
So after Left Joining two tables, I've got less rows on the output...
For many reasons it can be more rows due to duplicates etc., but it shouldn't be less rows.

What are the possible reasons and the solutions for that critical issue?

The keys are generated via Autonumber() and it has the same seed, furthermore I haven't got the NULLs on these fields.

I'll try to prepare the file and the script.

27-3-2017 16:41:31: 0030  Binary [..\XXX.qvw]

27-3-2017 16:41:51: 0031  Let vNumberOfRows = NoOfRows('FINAL')

27-3-2017 16:41:51: 0032  Trace 4877810

27-3-2017 16:41:51: 0032  4877810

27-3-2017 16:41:51: 0033  Left  JOIN(FINAL)

27-3-2017 16:41:51: 0034  LOAD Distinct * RESIDENT D_XXX

27-3-2017 16:41:51:      11 fields found: %XXX.KEY, XXX.Name 4 516 lines fetched

27-3-2017 16:41:51:      Joining/Keeping

27-3-2017 16:42:08: 0035  Drop Table D_XXX

27-3-2017 16:42:09: 0036  Let vNumberOfRows = NoOfRows('FINAL')

27-3-2017 16:42:09: 0037  Trace 4219022

27-3-2017 16:42:09: 0037  4219022

Kind Regards,
Adam

Certified QS BA / DA Developer
Looking for the QS workaround for missing object properties
1 Solution

Accepted Solutions
adamjank
Contributor III
Contributor III
Author

Binary [..\XXX.qvw];

Let vNumberOfRows = NoOfRows('FINAL');

Trace $(vNumberOfRows);

Left  JOIN(FINAL)

LOAD *;

LOAD DISTINCT * RESIDENT D_XXX;

Drop Table D_XXX;

Let vNumberOfRows = NoOfRows('FINAL');

Trace $(vNumberOfRows);

Solution, so the DISTINCT does not affect the first table.

THANK YOU A LOT jontydkpi

Certified QS BA / DA Developer
Looking for the QS workaround for missing object properties

View solution in original post

11 Replies
sunny_talwar

27-3-2017 16:41:31: 0030  Binary [..\XXX.qvw]

27-3-2017 16:41:51: 0031  Let vNumberOfRows = NoOfRows('FINAL')

27-3-2017 16:41:51: 0032  Trace 4877810

27-3-2017 16:41:51: 0032  4877810

Do you have a where statement here? 0032?

adamjank
Contributor III
Contributor III
Author

It's just a plain binary load without any 'where', additional conditions.

Certified QS BA / DA Developer
Looking for the QS workaround for missing object properties
sunny_talwar

Would you be able to share the script

adamjank
Contributor III
Contributor III
Author

Binary [..\XXX.qvw];

Let vNumberOfRows = NoOfRows('FINAL');

Trace $(vNumberOfRows);

Left  JOIN(FINAL)

LOAD Distinct * RESIDENT D_XXX;

Drop Table D_XXX;

Let vNumberOfRows = NoOfRows('FINAL');

Trace $(vNumberOfRows);

Certified QS BA / DA Developer
Looking for the QS workaround for missing object properties
sunny_talwar

Ya that is weird... may be pcammaert‌ can offer his expert advice here

jonathandienst
Partner - Champion III
Partner - Champion III

I think this is due to some quirky behaviour in the way QV handles DISTINCT. If you join with a distinct table, the DISTINCT operation propagates upward to the first table, so it de-duplicates the first table, reducing the number of rows.

To avoid this, assuming you need the DISTINCT, you may need to distinct load the second table into a resident table, and then left join the resident table to the binary loaded table.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
adamjank
Contributor III
Contributor III
Author

Binary [..\XXX.qvw];

Let vNumberOfRows = NoOfRows('FINAL');

Trace $(vNumberOfRows);

Left  JOIN(FINAL)

LOAD *;

LOAD DISTINCT * RESIDENT D_XXX;

Drop Table D_XXX;

Let vNumberOfRows = NoOfRows('FINAL');

Trace $(vNumberOfRows);

Solution, so the DISTINCT does not affect the first table.

THANK YOU A LOT jontydkpi

Certified QS BA / DA Developer
Looking for the QS workaround for missing object properties
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Indeed.

Funny that a Preceding Load apparently also blocks the DISTINCT propagation. Should check this out.

Peter_Cammaert
Partner - Champion III
Partner - Champion III

This is getting weird. In Adams last post, the DISTINCT keyword doesn't work at all, not even in the 2nd table (the one that is loaded first). How crazy can this become?

For example, how many rows do you get in the final copy of the RawData table?

RawData:

LOAD * INLINE [

Prod, Cust, Items

A, C1, 5

B, C1, 3

C, C2, 10

C, C3, 5

C, C3, 5

A, C1, 5

B, C1, 3

];

LET vNumRows =  NoOfRows('RawData');

TRACE >>>>> RawData before JOIN: $(vNumRows) rows;

LEFT JOIN (RawData) LOAD *;

LOAD DISTINCT * INLINE [

Prod, ProdName

A, Food

B, Brick

C, Chair

C, Chair

B, Brick

A, Food

];

LET vNumRows =  NoOfRows('RawData');

TRACE >>>>> RawData after JOIN: $(vNumRows) rows;