Skip to main content

App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Qlik Cloud Maintenance is scheduled between March 27-30. Visit Qlik Cloud Status page for more details.
cancel
Showing results for 
Search instead for 
Did you mean: 
nihhalmca
Specialist II
Specialist II

Duplicate values are not considering while using where exists

Hi All -

My requirement is as follows

 

Source:

Period Name Sales
Q12021 A 100
Q12021 B 200
Q22021 N 20
Q22021 D 50
Q32021 M 150
Q32021 H 250
Q42021 L 200
Q42021 C 500

 

Script:

nihhalmca_1-1639421605324.png

Result:

nihhalmca_0-1639421536146.png

Expected Result:

Period Name Sales
Q12021 A 100
Q12021 B 200
Q22021 N 20
Q22021 D 50
Q32021 M 150
Q32021 H 250
Q42021 C 500
Q42021 L 200

 

Duplicate values are not considering while using where exists, is it possible to achieve expected results.

Appreciate your help, thanks

1 Solution

Accepted Solutions
Or
MVP
MVP

As the Qlik documentation highlights:

"You can also use Not Exists() to determine if a field value has not been loaded, but caution is recommended if you use Not Exists() in a where clause. The Exists() function tests both previously loaded tables and previously loaded values in the current table. So, only the first occurrence will be loaded. When the second occurrence is encountered, the value is already loaded."

In other words, for your example, all Q42021 values will be loaded from the first load, and then the first value for each period (excluding Q42021) will be loaded from the second table. This is correct behavior.

See the documentation for a suggestion on how to work around this that you may be able to use.

https://help.qlik.com/en-US/qlikview/May2021/Subsystems/Client/Content/QV_QlikView/Scripting/InterRe...

[...]

To be able to get all values for Lucy you need to change two things:

  • Add a preceding load to Employees where you rename Employee to Name.

    Load Employee As Name, ID, Salary;

  • Change the Where condition in Citizens to:

    not Exists (Name, Employee).

View solution in original post

2 Replies
Or
MVP
MVP

As the Qlik documentation highlights:

"You can also use Not Exists() to determine if a field value has not been loaded, but caution is recommended if you use Not Exists() in a where clause. The Exists() function tests both previously loaded tables and previously loaded values in the current table. So, only the first occurrence will be loaded. When the second occurrence is encountered, the value is already loaded."

In other words, for your example, all Q42021 values will be loaded from the first load, and then the first value for each period (excluding Q42021) will be loaded from the second table. This is correct behavior.

See the documentation for a suggestion on how to work around this that you may be able to use.

https://help.qlik.com/en-US/qlikview/May2021/Subsystems/Client/Content/QV_QlikView/Scripting/InterRe...

[...]

To be able to get all values for Lucy you need to change two things:

  • Add a preceding load to Employees where you rename Employee to Name.

    Load Employee As Name, ID, Salary;

  • Change the Where condition in Citizens to:

    not Exists (Name, Employee).

nihhalmca
Specialist II
Specialist II
Author

Thank you.