Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Qlikuser09
Creator II
Creator II

Set analysis code (if)

i am looking for a set analysis code to convert (if there are more than 1 id Count for a specific field (product) then divide 1 by that count of id something like (1/n) where n is the count of id.

Customer IDProducts 1
1Pen 
2pencil
3book
4Eraser
5Pen 
6pencil
7book
8pen 
8pencil
9Book 

9

9

Eraser

Eraser

10Pencil
10

Book

 

Here the count if ID - (10) is 2  so the result will be 1/2=0.5, for id 9 it will be 1/3=0.33

2 Solutions

Accepted Solutions
AshutoshBhumkar
Partner - Specialist
Partner - Specialist

Hi,

The result can be derived by Count (Distinct Customer ID) / Count (Customer ID)

AshutoshBhumkar_0-1631934648356.png

 

View solution in original post

Vegar
MVP
MVP

An expression always try to  split up the result per dimension combination in a chart. If you add Product and Customer  ID then it will calculate the count per Product and  Customer ID. 

You can override this behaviour by defining your aggregated scope using TOTAL

Try an expression like this:

Count (Distinct Customer ID) / Count (TOTAL <[Customer ID]> Customer ID) 

 

 

 

View solution in original post

7 Replies
AshutoshBhumkar
Partner - Specialist
Partner - Specialist

Hi,

The result can be derived by Count (Distinct Customer ID) / Count (Customer ID)

AshutoshBhumkar_0-1631934648356.png

 

Qlikuser09
Creator II
Creator II
Author

Set analysis code for "Count of Products for Distinct Customer ID" will that work?

AshutoshBhumkar
Partner - Specialist
Partner - Specialist

Hi, May I please know what output you are expecting?

Vegar
MVP
MVP

If @AshutoshBhumkar  solution  isn't enough to solve your problem, then you probably need to re-explain your issue in other words  in order for us to help you. 

Qlikuser09
Creator II
Creator II
Author

Customer IDProductsCalculated Count
  0.333
9Pen1
9Paper1
9Book1

 

This is the result I am getting also the bar graph shows 1, 1, 1 for each product, which in turn gives the wrong Customer ID count. I am not getting the 0.33 value for each product. Also if I put a count  (CustomerID) the result displays as 1 and not as 3, but when I try putting it in the chart the result gets split.

Vegar
MVP
MVP

An expression always try to  split up the result per dimension combination in a chart. If you add Product and Customer  ID then it will calculate the count per Product and  Customer ID. 

You can override this behaviour by defining your aggregated scope using TOTAL

Try an expression like this:

Count (Distinct Customer ID) / Count (TOTAL <[Customer ID]> Customer ID) 

 

 

 

Qlikuser09
Creator II
Creator II
Author

Thanks this worked for me in table chart!! however,  I added this to the bar chart, the value still shows 1 for each product.