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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
bvmike2001
Contributor III
Contributor III

Calculate dimension for pie chart

Hi,

I have the following scenario:

one Customer table and one Sales table; linked together in the model by Customer_ID, let's say

I need to create a pie chart that count the # of Customers over a dimension with these segments:

- No Sales

- with Sales

The expression is simple: count(distinct Customer_ID)

The issue is that the calculated dimension and the expression doesn't return anything for "No Sales" so the pie chart only display the # of Customers with Sales.

Is it possible to solve it without any joins in the model?

Regards,

Mihai

1 Solution

Accepted Solutions
Clever_Anjos
Employee
Employee

Please try with a dimensionless pie chart adn 2 expressions

Exp1: count(distinct {<Customer_ID={"=Sum(Sales)=0"}>}Customer_ID)

Exp2: count(distinct {<Customer_ID={"=Sum(Sales)>0"}>}Customer_ID)

I´m assuming that your metric field is called "Sales"

View solution in original post

7 Replies
Clever_Anjos
Employee
Employee

Please try with a dimensionless pie chart adn 2 expressions

Exp1: count(distinct {<Customer_ID={"=Sum(Sales)=0"}>}Customer_ID)

Exp2: count(distinct {<Customer_ID={"=Sum(Sales)>0"}>}Customer_ID)

I´m assuming that your metric field is called "Sales"

Kushal_Chawda

what is calculated dimension?

bvmike2001
Contributor III
Contributor III
Author

I've try it and didn't get the expected result. I will add some more details: Cust: load * Inline [ Cust_Id, Name 1,A 2,B 3,C 4,D ]; Sales: load * Inline [ Cust_id, Sales 1,100 2,20 3,30 ] The pie chart should count 3 customers with sales and 1 customer without sales. Regards, Mihai

Clever_Anjos
Employee
Employee

It seems correct to me

Clever_Anjos
Employee
Employee

PFA

bvmike2001
Contributor III
Contributor III
Author

Yes!

Thank you, Anjos!

Could you explain please the logic inside the set analysis? I never used such.

Clever_Anjos
Employee
Employee

Set Analysis is equivalent to a selection made into a listbox

count(distinct {<Customer_ID={"=Sum(Sales)=0"}>}Customer_ID) means

Make a selection into Customer_ID field retrieving all customers that have Sum(Sales)=0, meaning "NO SALES" at all

count(distinct {<Customer_ID={"=Sum(Sales)>0"}>}Customer_ID) means

Make a selection into Customer_ID field retrieving all customers that have Sum(Sales)>0, meaning this customer have had sales