Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Gysbert_Wassenaar

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

View solution in original post

4 Replies
Gysbert_Wassenaar

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
Author

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

Thanks

Not applicable
Author

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)  

Gysbert_Wassenaar

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