Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
cthomas2
Contributor II
Contributor II

Please help with getting answer from data

Hello,

I am curious how I can get an answer based on a group of data and then count the "index" that represents that group... here is an example very simplified table:

IndexValue
1a
1a
1b
2a
2a
2a
3a
3b
4a
5b

Effectively, I am trying to count the number of indices that distinctly have a value of 'a'. 1 would not be counted because the 3rd record contains a b, 2 would be counted because it only contains the value a (but is only counted once), 3 would not, 4 would count and 5 would not... so when I run the expression on the above table, the resulting count would be 2.

I actually have another level to add to this, but I think if I can understand how to accomplish my goal on just this set of data, I could extract what I need on the larger set...

Any help on this one? Thanks in advance!

1 Solution

Accepted Solutions
MarcoWedel

Hi,

another expression might be:

QlikCommunity_Thread_300537_Pic1.JPG

hope this helps

regards

Marco

View solution in original post

8 Replies
jwjackso
Specialist III
Specialist III

Using the AGGR function, if the number of distinct counts is 1, return 1, otherwise 0.  Suppress zeroes rows.

AGGR.PNG

ehilsinger
Contributor III
Contributor III

I created a chart with the Index as a dimension and this as the expression.

= Count ({$<[Index] -= P({<[Value] -= {'a'}>})>}  Distinct [Value])

Will this get you started?

maxgro
MVP
MVP

try

- (only(TOTAL <Index> Value) = 'a')

1.png

cthomas2
Contributor II
Contributor II
Author

Thanks for the response, however 3 is incorrect as the distinct values needs to be specifically 'a'.

cthomas2
Contributor II
Contributor II
Author

This result looks correct, however I just get a memory allocation error when I try putting it in and changing Index & Value for the actual field names...

MarcoWedel

Hi,

another expression might be:

QlikCommunity_Thread_300537_Pic1.JPG

hope this helps

regards

Marco

qlikviewwizard
Master II
Master II

Try this in a text object.

=count(distinct aggr((only(TOTAL <Index> Value) = 'a'),Index))

cthomas2
Contributor II
Contributor II
Author

This is it! I was also able to integrate it into the "next level" I indicated into the original post and it matches up with all the counts I've already manually calculated.

It did not occur to me to just try to SUM the -1's, I kept trying to convert them into something else and then count them... such a simple change!

Thanks everyone for trying to help me with this... I learned a lot just from trying everyone's suggestions!