Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
eddywong71
Creator
Creator

How to create a new dimension split by Comma and count the value

My Dataset is like below.

Product
Apple,Orange
Apple
Orange
Orange, Banana
Banana
Apple,Orange,Banana

Then I create a new dimension : SubField([Product],',',1) as New Product. 

Product
Apple
Orange
Banana

May i ask what expression that i can use to count the product . I want the result as below.

Product Count
Apple 3
Orange 4
Banana 3
Labels (1)
1 Solution

Accepted Solutions
Fabiano_Martino_Intelco
Partner - Creator
Partner - Creator

Hi @eddywong71 

following the instructions of @marcus_sommer i created this script:

Fruits:
Load * Inline [
Buyer; Product
Sam; Apple,Orange
May; Apple
Mary; Orange
Tom; Orange,Banana
Andy; Banana
Peter; Apple,Orange,Banana
](delimiter is ';')
;
 
Fruits_Expanded:
Load
Buyer,
SubField(Product, ',') as Fruit
Resident Fruits;

 

You can then count the Fruit to get the total of each fruit.

Fabiano_Martino_Intelco_0-1718898243583.png

The Count of Total Distinct Buyer will get the base to measure the product penetration.

Regards

Fabiano

View solution in original post

7 Replies
BrunPierre
Partner - Master
Partner - Master

?

Dimension: New Product

Measure: Count(Product)

eddywong71
Creator
Creator
Author

Hi BrunPierre,

Count(Product) can not have a correct result. The result will like

Product Count
Apple 3
Orange 2
Banana 1
marcus_sommer

Your dimension isn't suitable because you just takes the first fruit. Therefore remove the third parameter of subfield() which then worked as an internal loop and creating a new record for each sub-part - just:

SubField([Product],',') as New Product

eddywong71
Creator
Creator
Author

Can any one could help 🙏

eddywong71
Creator
Creator
Author

It is because I want to select all the fruit from the Product to become in single dimension. The data allow a row can include more than one fruit. Is there way to distinct all the fruit as dimension. Then count the fruit.

The Data as below.

Buyer Product
Sam Apple,Orange
May Apple
Mary Orange
Tom Orange, Banana
Andy Banana
Peter Apple,Orange,Banana

 

I want the result as below.

Product Product Penetration
Apple 3/6
Orange 4/6
Banana 3/6

 

Fabiano_Martino_Intelco
Partner - Creator
Partner - Creator

Hi @eddywong71 

following the instructions of @marcus_sommer i created this script:

Fruits:
Load * Inline [
Buyer; Product
Sam; Apple,Orange
May; Apple
Mary; Orange
Tom; Orange,Banana
Andy; Banana
Peter; Apple,Orange,Banana
](delimiter is ';')
;
 
Fruits_Expanded:
Load
Buyer,
SubField(Product, ',') as Fruit
Resident Fruits;

 

You can then count the Fruit to get the total of each fruit.

Fabiano_Martino_Intelco_0-1718898243583.png

The Count of Total Distinct Buyer will get the base to measure the product penetration.

Regards

Fabiano

eddywong71
Creator
Creator
Author

It works . Thanks so much !