Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Seiya
Contributor III
Contributor III

Count/GetSelectedCount not working as intended(?)

New topic related to an older unanswered one as I felt it best for a new post due to a chnage in the basis of the question.

Currently I have a bar graph that takes in a Product ID as it's dimension and a count of rejection codes (1.1, 2.1, 6.4, etc) that may be applied to the product giving me what amounts to a total of all products that have been rejected, regardless of what code it was rejected by.

This works fine until I want to filter it in the visualization by selecting a specific code or codes from the rejection table.

Using count or what I though was the correct method after count failed GetSelectedCount in the expressions field of the measures section however fails miserably.

When I select one or even 4 rejection codes, instead of returning the total count of all selected codes it instead returns 1 or 4... Gee, GetSelectedCount, you don't say? (insert Nicholas Cage meme here).

Well that's completely useless, what's the point in that? (Ok maybe I could see some kind of use in counting the number of selections... perhaps?)

To further illustrate for clarity using the table below:

ID     Rej Code

AA      1.1

AA      1.1

AA      1.1

AA      2.1

BB      2.1

BB      2.1

The unfiltered bar graph when using rejection code as a count measure should return 4 for AA and 2 for BB.

When selecting 1.1 from in the rejection code table during visualization it should be return 3 for AA and 0 for BB.

I did a search for this issue but I either have the syntax for the issue correct or there's a lack of information for what would appear to be a likely common problem?

5 Replies
Lisa_P
Employee
Employee

The correct expression is count([Rej Code])

GetSelectedCount() is used to see how many values have been selected/filtered per field

Seiya
Contributor III
Contributor III
Author

Ah yes sorry, Had to write this post 5 times cause the forum crashed multiple times on me and I missed something out.

It fails primarily when I use the expression" count([rej code])/count([product ID])" because I want a percentage of what was rejected filtered by rejection code.

Lisa_P
Employee
Employee

If you are using Product ID in a table or bar chart as a dimension then to see the %, you would change the expression to look at all products. ie count([rej code])/count(TOTAL product ID])

Seiya
Contributor III
Contributor III
Author

Thanks, almost there but not quite sorry.

Totals gets us the total of all product ID's against the selected count but I need the total of each product ID against the selected count of each selected rejection code.

So for example

instead of what we have now of

AA 50%

BB 30%

CC 20%

Adding to 100% for all products versus a selection of 1.1 lets say, I require:

AA 22% (100 products of AA/22 rejected at 1.1)

BB 9% (100 products of BB/9 rejected at 1.1)

CC 0% (2000 products of CC/no rejection at 1.1)

Seiya
Contributor III
Contributor III
Author

Looking at it again I believe one of the issues is that for rejection code, it tends towards 100% when selecting a rejection code because for products that are not rejected it that field is empty and not counted.

So when a code is selected it ignores null and thus only sees all products rejected by that one code and not the ones that passed quality (empty data field).

Edit: Solved with count(reject code)/count({<reject code=>} product ID)