Knowledge Base
Open App
KB 100504

Filtered table as filter argument (multiple columns predicate with AND condition over ALL table rows)

A FILTER function filtering ALL the rows of an entire table using an AND condition on multiple columns is used as a filter argument in functions such as CALCULATE, CALCULATETABLE, etc.


Because the conditions are applied with an && operator, the multiple columns predicate can be transformed into one filter argument for each column, without filtering an entire table.

In order to keep the same semantics as the original filter, apply REMOVEFILTERS on the previously iterated table because the iterator was over ALL of that table.

Recommended articles:


Replace the Customer iterator with a REMOVEFILTERS over Customer, and move each && condition in a different filter argument, so the filter is applied only to the Customer[Country] and Customer[Age] columns instead of filtering the entire Customer table.

Original code

    [Sales Amount],
    FILTER (
        ALL ( Customer ),
        Customer[Country] = "Canada" 
            && Customer[Age] >= 21

Possible optimization

    [Sales Amount],
    REMOVEFILTERS ( Customer ),
    Customer[Country] = "Canada",
    Customer[Age] >= 21