Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Help with Set analysis

Simple example : let's say I have a data set with only one column containing colors (red, yellow, blue for instance).

I want to display a table containing :

     -the number of occurence of each color

     -the relative proportion of each color to the red one

ex.

Blue

Red

Red

Blue

Yellow

Blue

would give me

COLOR| Nbr occ | Relative to red

Red      | 2           | 1

Yellow  | 1           | 0,5

Blue     | 3           | 1,5

For the relative proportion to red I tried something like

=count(Color)/count({1 <Color={"Red"}>} Color)

but it gives 0 for the Yellow and Blue row.

What am I doing wrong?

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Yes this works! Thanks!

View solution in original post

6 Replies
alexandros17
Partner - Champion III
Partner - Champion III

Try this expression

Count(colour)/Count({$ <colour={'Red'}>} TOTAL colour)

Gysbert_Wassenaar

No idea. It works fine for me. See attached qvw.

Make sure to use the exact case sensitive field name. COLOR, color and Color are three different fields to Qlikview.


talk is cheap, supply exceeds demand
Anonymous
Not applicable
Author

Yes this works! Thanks!

Anonymous
Not applicable
Author

My point was being able to calculate the total number of Reds for each row, the solution suggested by Alessandro works

Doesn't work :

                         count(Color)/count({1< Color={'Red'}>} Color)

Works :

                         count({$ <Color={'Red'}>} TOTAL Color)

alexandros17
Partner - Champion III
Partner - Champion III

Could you please mark the question as answered? Thanks

Gysbert_Wassenaar

Oh, you wanted that in a straight/pivot table. Yes, then all you need to do is add the total keyword.


talk is cheap, supply exceeds demand