Checks whether a condition is met, and returns one value if TRUE, and another value if FALSE. Uses eager execution plan.
Any value or expression that can be evaluated to TRUE or FALSE.
The value that is returned if the logical test is TRUE.
The value that is returned if the logical test is FALSE; if omitted, BLANK is returned.
Either ResultIfTrue or ResultIfFalse expression result, depending on LogicalTest.
The result data type can be variant if ResultIfTrue and ResultIfFalse are of different data types. The function attempts to return a single data type if both ResultIfTrue and ResultIfFalse are of numeric data types. In the latter case, the IF.EAGER function will implicitly convert data types to accommodate both values.
IF.EAGER has the same functional behavior as the IF function, but performance may differ due to differences in execution plans. IF.EAGER has the same execution plan as the following DAX expression:
VAR _value_if_true = <ResultIfTrue> VAR _value_if_false = <ResultIfFalse> RETURN IF ( <LogicalTest>, _value_if_true, _value_if_false )
Note: The two branch expressions are evaluated regardless of the condition expression.
Calling IF.EAGER enforce eager evaluation of the conditional expression, instead of relying on choice between strict and eager evaluation made by the DAX engine.
This function should be used only in very particular case of DAX optimization, after verifying that it produces a clear performance advantage compared to the regular IF function.
» 3 related functions
-- The engine can use either STRICT or EAGER evaluation. -- The choice is up to the optimizer. -- Using IF.EAGER you can force eager evaluation of IF statements. -- Useful in some optimization scenarios. DEFINE MEASURE Sales[GrossAmount] = SUMX ( Sales, Sales[Quantity] * Sales[Unit Price] ) MEASURE Sales[NetAmount] = SUMX ( Sales, Sales[Quantity] * Sales[Net Price] ) EVALUATE ADDCOLUMNS ( VALUES ( 'Product'[Brand] ), "Sales", IF ( 'Product'[Brand] = "Contoso", [GrossAmount], [NetAmount] * 1.5 ) ) ORDER BY 'Product'[Brand]
|The Phone Company||1,685,728.60|
|Wide World Importers||2,852,934.98|
Learn more about IF.EAGER in the following articles:
Other related functions are:
Contributors: Alberto Ferrari, Marco Russo
Microsoft documentation: https://docs.microsoft.com/en-us/dax/if-eager-function-dax