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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
ck14nobel
Contributor
Contributor

Count Problem

Hi,

this is my first post after learning a lot from this forum. Thanks a lot.

I hope you can help me with this problem, because I didn't find a solution yet.

I have a table of order positions with OrderIDs and CustomerIDs. Each Order can have multiple rows (order positions) in the table.

In a pivot table I have to answer the following questions:

- How many orders do I have?  --> Count (DISTINCT OrderID)

- How many customers do I have?  --> Count (DISTINCT CustomerID)

- How many customers ordered in exactly one order???

- How many customers ordered in multiple orders???

This is a short extract of my table:    

OrderIDCustomerIDQuantityPrice
17348721002392463,7
17703721010522150,38
17703721010522238,57
17711721008542443,53
17723821010522433,45
17816621012682113,4
17816721012682453,61
17816821012682113,4
17827121000752216,72
17827121000752216,72

As you can see customer 1010522 has two orders (1770372 and 1772382), customer 1012682 has three orders.

So I have two customers with multiple orders and three customers with exactly one order. That's what I need expressions for.

A lot of thanks in advance.

Labels (1)
1 Solution

Accepted Solutions
sunny_talwar
MVP
MVP

May be this:


- How many customers ordered in exactly one order??? --> Count (DISTINCT {<CustomerID = {"=Count (DISTINCT OrderID) = 1"}>} CustomerID)

- How many customers ordered in multiple orders??? --> Count (DISTINCT {<CustomerID = {"=Count (DISTINCT OrderID) > 1"}>} CustomerID)

View solution in original post

2 Replies
sunny_talwar
MVP
MVP

May be this:


- How many customers ordered in exactly one order??? --> Count (DISTINCT {<CustomerID = {"=Count (DISTINCT OrderID) = 1"}>} CustomerID)

- How many customers ordered in multiple orders??? --> Count (DISTINCT {<CustomerID = {"=Count (DISTINCT OrderID) > 1"}>} CustomerID)

ck14nobel
Contributor
Contributor
Author

Many thanks Sunny, that works for me.