'How to apply different and/or groups for multiple filters in PHP GA4?
I have to pull data using mutiple dimension filters using AND/OR operators in php GA4. How to apply AND operator for the below dimension filters -
'dimensionFilter' => new FilterExpression([
        'filter' => new Filter([
            'field_name' => 'dayOfWeek',
              'string_filter' => new Filter\StringFilter([
              'match_type' => Filter\StringFilter\MatchType::EXACT,
              'value' => '5',
             ])
        ]),    
        'filter' =>    new Filter([
            'field_name' => 'pagePath',
            'string_filter' => new Filter\StringFilter([
              'match_type' => Filter\StringFilter\MatchType::EXACT,
              'value' => '/tmp/73.html',
             ])
        ])
    ]),
							
						Solution 1:[1]
For applying multiple dimension filter using and operation, use 'and_group' and 'FilterExpressionList' -
'dimensionFilter' => new FilterExpression([
        'and_group'=>  new FilterExpressionList([
            'expressions'=> [
                new FilterExpression([                
                    'filter' => new Filter([
                        'field_name' => 'dayOfWeek',
                        'string_filter' => new Filter\StringFilter([
                          'match_type' => Filter\StringFilter\MatchType::EXACT,
                          'value' => '5',
                         ])
                    ]),   
                ]),     
                new FilterExpression([
                    'filter' =>    new Filter([
                        'field_name' => 'pagePath',
                        'string_filter' => new Filter\StringFilter([
                          'match_type' => Filter\StringFilter\MatchType::EXACT,
                          'value' => '/tmp/73.html',
                         ])
                    ])
                ]),     
            ]
        ]),
 ]),            
more and/or/not_expression filters can be combined as in nested conditions to get the desired results.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source | 
|---|---|
| Solution 1 | user3391295 | 
