Knowledge Base
Open App
KB 102401

MAXX/MINX function with IF predicate on iterator column

The MAXX / MINX function contains an IF predicate on a single column filtering the iterated table.


The IF condition in an iterator can be expensive from a performance standpoint. When the condition only references columns of the iterated table (or the expanded table using RELATED), then it is possible to filter the table through the filter context by using CALCULATE.


Remove the IF condition and use CALCULATE to filter the table moving the condition into a filter argument; use KEEPFILTERS to preserve the same semantics.

Original code

    IF ( Sales[Quantity] > 1, Sales[Quantity] * Sales[Net Price] )

Possible optimization

    MAXX (
        Sales[Quantity] * Sales[Net Price]
    KEEPFILTERS ( Sales[Quantity] > 1 )