Skip to main content

I want to filter based on a condition like this:

FILTER Color = 'blue' WHEN Shape = 'square'.

 

I'm having trouble creating a formula like this because what I have tried is filtering all instances where Color = 'blue', but I want to filter only for blue color when the shape is square.

I think this should be something very easy to do, but I'm having trouble.

 

Thanks in advance :)

Hi,

I am not completely sure if I understand your question correctly, this could be a simple OR, i.e.

FILTER Color='blue' OR Shape !='square'; (this would filter out all squares that are not blue but leave all other shapes in). For more elaborate statements you can also use

FILTER (

CASE

WHEN shape='square' AND color ='blue' THEN 1

WHEN shape='round' THEN 0

WHEN shape='triangle' AND color='red' THEN 1

....

END) = 1;

BR

Stephanie

 


" I want to filter only for blue color when the shape is square"

 

That would be done like this: FILTER Color = 'blue' AND Shape = 'square';

 

BR Florian


Hi Stephanie and Florian,

 

I have tried using the AND condition but is filtering both conditions. For this example: FILTER Color = 'blue' AND Shape = 'square'; it's filtering all the color=blue and shape=square. But it should only filter blue when shape is square.

 

Let's take as example the following table:

 

image.pngThe desired output is the following:

image.pngWhat I'm getting with FILTER Color = 'blue' AND Shape = 'square':

image 

Thanks,

Julio


Hi Julio,

according to your example you have a wrong understanding of what FILTER does. It is positive, i.e. FILTER shape='square' will filter for squares only and triangle will be EXCLUDED. In the above example

FILTER shape != 'square' OR color !='blue' will result in the desired output.

BR

Stephanie


@julio.bolan12 

Try below formula ,

 

FILTER shape != 'square' OR ( shape = 'square' AND  color !='blue' )


Reply