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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Selecting unique records using GetSelectedCount

Does anyone know how I can select unique records using the GetSelectedCount. I have an if statement that is used to color code my bubbles on a chart based on the the selection and if it is 1 or multiple records. The issue is that since the records are summed as part of the chart the underlying data has multiple records so I cannot use > 1.

Using Distint with a count does not work as it does not factor in my selections and it appears that I can't use the Distint with GetSelectedCount.

Does anyone have any ideas. I pasted sample code below however the entire code is pretty long since it relates to color coding a large combination of bubles.

 

=if
(
getselectedCount (Primary) <> 1
,

(if(Primary= 'Test',RGB(176,23,31), if(Primary= 'Test1',RGB(75,0,130), if(Primary= 'Test2',RGB(0,0,255), 

)))
)
,
(if(second= 'A',RGB(176,23,31), if(second= 'B',RGB(75,0,130), if(second= 'C',RGB(0,0,255)

)))
)
)

3 Replies
swuehl
MVP
MVP

Not sure if I've understood. AFAIK, GetSelectedCount(FIELD) returns the number of distinct values you selected in FIELD. For example:

LOAD * INLINE [

Test

A

B

B

C

C

C

];

If you create a text object with expression

=GetSelectedCount(Test)

and a list box with field Test, then select one value out of A,B or C, you will get a GetSelectedCount of  1, each time.

So there is no need for a DISTINCT in GetSelectedCount function (or I misunderstood your request).

Regards,

Stefan

Not applicable
Author

Stefan,

The issue is that the based on the hirearchy of the data the field I am using to code the colors are not unique.

For example in the table below I would using the GetSelectedCount on field Test which is not unique but I am pulling in feild Test2 into the chart.

Test          Test2

A               1

A               2

A               3

B               4

C               5

C               6

Not sure if this helps clarify or not.

Thanks!

swuehl
MVP
MVP

Well, I am still confused. If you select value A from Test, what do you get using GetSelectedCount( Test )? I would assume 1, not 3. Same with values B, C. So it should not matter if your values are unique or not for GetSelectedCount.

But maybe you could explain what you want to achieve with your code in more detail. You could also post a small sample app, this probably helps to understand your problem.