Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Oct 10, 2022 9:41:26 AM
Oct 10, 2022 9:41:26 AM
The script
Table1:
LOAD DISTINCT
Inline [
Field1, Field2, Field3
1, 2, 1
2, 2, 1
3, 3, 1
4, 3, 1];
DROP FIELD Table1.Field1;
creates a table with 4 rows. Some developers, especially if used to work with QlikView 11, would expect a 2 rows table. In fact, after Field1 is dropped, we can expect that the DISTINCT keeps only the distinct values from Field2.
This article explains how DISTINCT and DROP FIELD work in such a case.
We can follow the script execution to understand why a 4 row table is the logic result.
Field1 | Field2 | Field3 |
1 | 2 | 1 |
2 | 2 | 1 |
3 | 3 | 1 |
4 | 3 | 1 |
Field2 | Field3 |
2 | 1 |
2 | 1 |
3 | 1 |
3 | 1 |
It is possible to use a script like this to have the distinct check in the second part of the script :
tmp:
LOAD DISTINCT
Table1.Field2,Table1.Field3
resident Table1;
DROP Table Table1;
Table1:
NoConcatenate Load
*
Resident tmp;
DROP table tmp;
Combining DISTINCT and DROP FIELD can lead to unexpected result. The behavior has changed with respect to QlikView 11.
QV-2384
If I add a simple LEFT JOIN onTable1 after the DROP Field command, I get a different result in QV 12.70 and 12.80. In 12.80 the data is multiplied.
Table1:
LOAD Distinct * INLINE [
Field1, Field2, Field3
1, 2, 1
2, 2, 1
3, 3, 1
4, 3, 1
];
DROP FIELD Field1;
LEFT JOIN
LOAD * INLINE [
Field2, Value
2, x, 1
2, a, 1
];
Result in 12.70 (see also in attachment):
Result 12.80 (see also in attachment):
Why does QV 12.80 show a different behaviour here? I have already written a Qlik Community article about this: https://community.qlik.com/t5/QlikView-App-Dev/Difference-between-12-70SR2-and-12-80SR1-when-using-q...