Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
zer0
Contributor
Contributor

Set Analysis giving wrong results, issue with dimensional scope?

Dear experts,

I'm getting wrong results on a table that I feel is caused by something related to scope but I can't figure it out and been I've searching for hours. I feel like I'm missing something very simple.

Here's the basic data structure, there are "Actual Calls" and "Planned Calls" for each Customer for each Employee:

Data.PNG

 

I'm analyzing the data by employee in a table, and I've created a new measure "Called Customers", which is basically counting the number of customers with "Actuals Calls" > 0:

count({<Customer = {"=sum([Actual Calls])>0"}>}distinct Customer)

 

Here's the issue, if I add this measure to the table, notice that Emp1 has 8 "Called Customers", when in fact it has only 7 customer with Actuals Calls > 0.

Emp1.PNG

I think the problem comes because Cust08 is duplicated, it appears both for Emp1 and Emp2. For Emp1 it has 0 Actuals Calls but for Emp2 it has Actual Calls>0.

This is what I don't understand. For Emp1 Cust08 has 0 Actual Calls so it shouldn't be appearing in the measure. It's like the measure is looking at all customers first, and then applying the dimension. I would expect that because Employee is a dimension in the table, for row Emp1 it would only look at the rows for Employee1 in the data, and then calculate the measure, but somehow the Emp2 Cust08 is being included.

However, if I filter the Employee to only Emp1, then it does show the correct answer of 7:

filtered.PNG

What am I missing here? I want to solve this but most importantly to really understand the logic of why this is happening so any resources you could point me to to further understand this would be much appreciated.

I've also attached the sample file.

Thank you in advance!

Labels (2)
1 Solution

Accepted Solutions
Raja2022
Contributor III
Contributor III

You can also use this expression and it will give you the same result:

count({<ActualCalls = {"=[ActualCalls]>0"}>} Customer)

View solution in original post

4 Replies
Raja2022
Contributor III
Contributor III

Hello,

Can you please replace your set analysis:

From: count({<Customer = {"=sum([Actual Calls])>0"}>}distinct Customer)

To: count({<ActualCalls = {"=[ActualCalls]>0"}>} Employee)

Raja2022_0-1645833796079.png

Hope this helps...

 

Raja2022
Contributor III
Contributor III

You can also use this expression and it will give you the same result:

count({<ActualCalls = {"=[ActualCalls]>0"}>} Customer)

zer0
Contributor
Contributor
Author

Thank you Raja! That solved it.

It makes much more sense to use the set analysis on the actual field I'm trying to put the condition on. I guess before I was telling the engine to find all the customers with Actual Calls > 0 first, and then assign those to each Employee (where the duplication was causing the issue because Cust08 is also mapped to Emp1), instead of starting with selecting only the records with Actuals Calls > 0 first, and then assign the remaining Customers to each Employee.

Thank you for the quick reply!

Best

 

Raja2022
Contributor III
Contributor III

You are welcome... And your understanding is correct..

Have a nice day...