Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Not applicable

Display value, count of one field based on value of another field

Let's say that I have a CSV of individual product sales where one field is the product name (e.g., "900X") and another is the product type (e.g., "Retail," "Commercial").  I'm trying to show a table where the first column lists the product and the second is the count of the rows for that product provided it's only for type=retail; e.g., I want to do

    

     select name, count(1) from products where type = 'Retail'

For the first column, I want to only include names when the type is "Retail."   I tried

{$<type={"Retail"}>} name

but it's not valid.  I'm not sure how to say that I just want the value without any wrapping function call.

For the second column, the following appears to be syntactically correct:

count({$<type={"Retail"}>} name)

Any ideas?

1 Solution

Accepted Solutions

Re: Display value, count of one field based on value of another field

Just use the dimension 'name' for the first column. The expression count({$<type={"Retail"}>} name) will filter out the names that aren't of type Retail.


talk is cheap, supply exceeds demand
4 Replies

Re: Display value, count of one field based on value of another field

Just use the dimension 'name' for the first column. The expression count({$<type={"Retail"}>} name) will filter out the names that aren't of type Retail.


talk is cheap, supply exceeds demand
Not applicable

Re: Display value, count of one field based on value of another field

Okay, so applying the constraint to the count apparently also applies it to the first column.

Thanks

Not applicable

Re: Display value, count of one field based on value of another field

One more quick question:  Is there way to constrain widgets that only have dimensions (no measures)?  It seems like there ought to be a way to apply constraints to them, e.g.,

({$<field2={"field2value"}>} field1)   // no wrapping function

someValueFunction({$<field2={"field2value"}>} field1)  

Re: Display value, count of one field based on value of another field

You'll have to use a calculated dimension like this one =if(field2='field2value',field1). Or perhaps aggr(only({<field2={'field2value'}>}field1),field1).


talk is cheap, supply exceeds demand
Community Browser