Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Monthly distribution percentage

Hi all!

Please help me! I have a table like this:

YearMonth
Customer
Product
Distribution
201103AX0
201103BX1
201103CX1
201104AX1
201104CX1
201104DX1
201105AX0
201105CX1

It contains many customers, many products and distribution. Distribution contains 0 or 1. 1 if the product presents at the customer.

I would like to create a bar chart, and calculate distribution percentage by product by YearMonth.

In sql like this:

select YearMonth, Product, sum(Distribution) / count(Customer)

from

group by Yearmonth, Product

How can I create this in QlikView?

Thanks a lot!

Waryou

1 Solution

Accepted Solutions
Michiel_QV_Fan
Specialist
Specialist

Untested:

aggr(count(DISTINCT customer), month) / aggr(count(DISTINCT Customer_ID), month)

Count does work but try adding a calculation field with a numeric value and use sum instead. A Qlikview best practice.

View solution in original post

6 Replies
francisvandergr
Partner - Creator II
Partner - Creator II

With Bar chart you can choose on the expressions Tab the option Relative. This option gives you a percentage.

Not applicable
Author

Hi,

When QlikView count the distribution percentage, collects all Customers. This is wrong, because there are different customers in different months.

In SQL group by handle this. But how can I do this in QlikView?

Michiel_QV_Fan
Specialist
Specialist

Check the aggr function.

Not applicable
Author

Expression is:

count({<Distr= {'>0'} >} DISTINCT  Customer)  / count(DISTINCT Customer_ID )

How can I count customers monthly, if the table contains several month and each month has different customers?

Michiel_QV_Fan
Specialist
Specialist

Untested:

aggr(count(DISTINCT customer), month) / aggr(count(DISTINCT Customer_ID), month)

Count does work but try adding a calculation field with a numeric value and use sum instead. A Qlikview best practice.

Not applicable
Author

Thank You! It seems aggr() function is working.