Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Not applicable

Trouble with count DISTINCT

I'm bumbling my way through using expressions as measures for bar charts, and so far I have the following working expression, which counts people based on specific values for two different fields:

count({$<[Past Rank]={"MS","PhD"}, [Role]={"Camper"}>} [Past Rank])

The source data (uploaded from an xls file) contains multiple lines per person, so now I'm trying to figure out how to adjust the expression shown above so that it only counts each person once.  I'm guessing that I need to somehow specify that the count should look at the [Person ID] field and use the word DISTINCT.  However, I'm at a loss as to how to do that.

My attempt below does NOT work:

count({$<[Past Rank]={"MS","PhD"}, [Role]={"Camper"}>} DISTINCT [Person ID])


I'm still fairly new and I'm having trouble figuring out the syntax.


Thanks!


Tom

1 Solution

Accepted Solutions

Re: Trouble with count DISTINCT

count({$<[Past Rank]={'MS','PhD'}, [Role]={'Camper'}>} DISTINCT [Person ID])


i.e. Single Quote instead of Double ...

6 Replies

Re: Trouble with count DISTINCT

count({$<[Past Rank]={'MS','PhD'}, [Role]={'Camper'}>} DISTINCT [Person ID])


i.e. Single Quote instead of Double ...

MVP
MVP

Re: Trouble with count DISTINCT

the syntax of your expression seems correct, could you post the excel source file or the .qvw?

Not applicable

Re: Trouble with count DISTINCT

Thanks Manish - what do single vs. double quotes mean in the expression?

Not applicable

Re: Trouble with count DISTINCT

Actually, I think I found the answer here: QlikView Quoteology

"Single quotes are used to quote literals, e.g. strings that should be used as field values."

Re: Trouble with count DISTINCT

QlikView Quoteology

Oh... I am late..

MVP
MVP

Re: Trouble with count DISTINCT

Thomas (and Manish too): It should be as you said

but in set analysis (today, see Henric ... in the same post) single or double quotes doesn't matter

and also it works without quotes (if you don't have spaces); this is from QlikView online help

sum( {$<Year = {2000}, Region = {US, SE, DE, UK, FR}>} Sales )

this is the reason I asked for the excel source file