Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

count of children of a parent product

Hi,

I have a problem with the parent child calculation in my pivot table. I have a dimension as product_id and I want to count of the products which are the child of the particular product_id. I can't use the "parent_id" as a dimension because of the remaining part of the table.

For example. Product 1 has three children product as 2,3 and 4. All the products except the parents contains the parent_id. For product 2 product_id=2 and parent_id = 1. My table should look like this.

product_idCount of the childs
13

I will be glad if you help me.

1 Solution

Accepted Solutions
Not applicable
Author

Look on first column of your chart,

I hope it helps!

Of course let me know if you have some questions

regards

Darek

View solution in original post

19 Replies
its_anandrjs

Write like

Count(Distint Child Id)

If possible provide sample for this

MK_QSL
MVP
MVP

Can you post your sample data file or apps?

Not applicable
Author

The sample file is attached. In this example the chart should show 3 as the number of the children when the 170769 selected. Again I can not use parent_id as dimension.

MK_QSL
MVP
MVP

are you sure the answer should be 3 and not 4?

use as below

count(TOTAL product_id)

its_anandrjs

If you count product_id in place of the parent_id for child id and i think it is 4 not 3 explain with more example.

its_anandrjs

Write like for straight table

Dimension :- product_id

Expression :-

Count(All parent_id)

Or

Count(All parent_id)

Not applicable
Author

You are right it will be 4. I mistyped it. count(total product_id) won't work because there are other products in the list. I will add other products to the file. The result should be product 170769 has 4 children and 209057 has 5 children.

MK_QSL
MVP
MVP

COUNT(TOTAL <parent_id> DISTINCT product_id)

Not applicable
Author

Hi Manish, your calculation  will work if I use "parent_id" as a dimension. On the other hand, my dimension has to be "product_id". I think the hard part of the problem is this.