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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Counting customers that have ordered in x categories

Hi

This is probably a very simple question but i am quite new to QV so any help would be appreciated.

I need to create a bar chart that counts distinct customers that have ordered in 1 - 13 categories.

Would I write this in the expression or create a calculated dimention?

Any example of how this might be written woudl be really helpful.

thanks

Heather

16 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Maybe count({<customer={'=count(distinct categories)<14'}>}distinct customer). If not, please post an example document with some data and what the resulting counts should be.


talk is cheap, supply exceeds demand
richard_chilvers
Specialist
Specialist

Hi

I would have tried setting category as the (only) dimension (with a selection of the correct categories as necessary) and a single expression COUNT(DISTINCT CUSTOMER). If you're new to QlikView, the Chart wizard will guide you through.

But, as Gysbert suggests, if this doesn't work well, then post us some examples of what you've tried.

Not applicable
Author

Hi

Thanks for the responses. I'll try and explain myself a bit better. I need the bar chart to show 13 bars, numbered 1 to 13, each column must represent the number of categories a customers has purcahsed in in the current year.

it doesnt matter if the categorys are different i.e if some one has bought Stationery and IT, and someone else has bought Art and Cleaning, they woudl both appear in the '2' column. I think I need to create buckets in a calculated dimention as Category will be a filter so the chart needs to reflect selections made here too.

Does that make more sense?

richard_chilvers
Specialist
Specialist

Hi Heather

Yes, I do understand the issue now, I think.

I don't have an obvious solution; looks like it might need a calculated dimension and I'm no expert on those. But I might take a look when I get 5 minutes

Not applicable
Author

Thanks Richard

Not applicable
Author

I can create the following table using these expressions;

2015               count({<[Year] ={$(vMaxYear)}>} distinct Category)

2014 YTD       count({<[Year] ={$(vPrevYear)}, [Financial Week #] = {'<=$(vMaxWeek)'}>} distinct Category)

2014 Full        count({<[Consortium Year] ={$(vPrevYear)}>} distinct Category)

Which gives me this:

Customer20152014 YTD2014 Full
21001
22001
24004
29003
30001
41002
50302
51002
52008
53003
58203
59003

etc

From there you can seet the number of customers that have purchased  in 'x' categories;

Categories20152014 YTD2014 Full
01887217521850
13927467610631
2246225463740
3198020892832
4168817652433
5140614412175
6104011181896
77878781699
85535991582
93323711568
101882051503
1169901467
121217940

I need to create this (exclusing the count for customers purchasing in 0 categories)example.jpg











flipside
Partner - Specialist II
Partner - Specialist II

Hi Heather,

You've lost me with this new information, but with my small dataset I think I'm getting what you originally needed.

Calculated dimension: =aggr(count(distinct Category),Customer)

Expression: =count(distinct Customer)

I'm not sure how it would fit with the dates, possibly three expressions with the set analysis as you have above.

flipside

Not applicable
Author

Hi, thanks for the reply, i've tried this but it puts the customer in the bucket of the maximum number of categories they're purchased in regardless of year. (even when i specift the year in the expressions).

flipside
Partner - Specialist II
Partner - Specialist II

Yes, it gets complicated when years are added in. I've tried lots of different combinations in the expression and get close but not close enough. I wonder if creating a new field in script which is a combo of year and category will stop it calculating the max number of categories.

flipside