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

Announcements
FLASH SALE: Save $500! Use code FLASH2026 at checkout until Feb 14th at 11:59PM ET. Register Now!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

getting a count

hi, I have fields like BRAND, CATEGORY, LOCATION and ITEM. I want to get the count of ITEM when i selected each field. As an example, if I selected one of the BRAND then how many ITEMs are there and If I selected a BRAND and one of its CATEGORY then ITEM count should be change. how can I do this. pls help

1 Solution

Accepted Solutions
gopalopsharma
Creator
Creator

Hello Dushan,

I assume you have a text value in ITEM field.

We can statistics only for the fields which have numeric values, but only one field at a time.

We have better ways to do it in straight table.

1. Create a cyclic group for the BRAND, CATEGORY, LOCATION

2. Insert a straight table and enter Cyclic group name in the dimension.

3. In the expression enter COUNT(DISTINCT ITEM)

It should help.

There is even one better way to do this, it is advised not to use COUNT so we can create an additional column which will have just single value 1 like below:

LOAD
     *,

     1 as CountFlag

FROM []

Then in the table above use Sum(CountFlag) and it will be much performance optimized. The only thing is that ITEM should be the most granular level in data. Since one CountFlag will refer to one ITEM.

Hope it helps..

View solution in original post

4 Replies
Not applicable
Author

can I use a static box for this? I only want to get the item count.

Not applicable
Author

when i use total count with the static box for Item, then it displays N\A. why is that?

gopalopsharma
Creator
Creator

Hello Dushan,

I assume you have a text value in ITEM field.

We can statistics only for the fields which have numeric values, but only one field at a time.

We have better ways to do it in straight table.

1. Create a cyclic group for the BRAND, CATEGORY, LOCATION

2. Insert a straight table and enter Cyclic group name in the dimension.

3. In the expression enter COUNT(DISTINCT ITEM)

It should help.

There is even one better way to do this, it is advised not to use COUNT so we can create an additional column which will have just single value 1 like below:

LOAD
     *,

     1 as CountFlag

FROM []

Then in the table above use Sum(CountFlag) and it will be much performance optimized. The only thing is that ITEM should be the most granular level in data. Since one CountFlag will refer to one ITEM.

Hope it helps..

Not applicable
Author

Thanks Gopal