Frequent Visitor
Posts: 8
Registered: ‎06-26-2016

Composable DAX Table Functions

CALCULATE() AND CALCULATETABLE() are the only two functions for manipulating filter context (adding to, replacing, or ignoring other filters) so these have to be at the top of my list but it's the functions you pass to them as filter arguments, and sometimes the functions within these functions, that really unleashes the power of DAX.


ALL() is often one of these common filter arguments as you want your expression to ignore a filter on a particular column, the entire table, or all columns in the table except a few columns (use ALLEXCEPT() function) .


FILTER() is another very common argument function for CALCULATE() that enables you to pass in a 'rich' filter argument such as a measure which isn't allowed by CALCULATE or CALCULATETABLE() alone.


So you'll often see expressions like the following:


MyMetric:= CALCULATE([MetricA],FILTER(ALL(Product),[MySalesMetric] > 500))


In this case we want to modify the filter context applied to Metric A - we want to remove all filters on the Product table via ALL but then filter the rows of this full table (one by one, iterating with FILTER) by a metric (MySalesMetric) such that only rows with over 500 are included. This final, modified Product table is used via relationship to your Fact table (of MetricA) to filter out its rows and then compute MetricA.


VALUES() is very important and flexible as well for working with individual columns. Values - Power Pivot Pro


The new CROSSFILTER function will be extremely useful for working with complex models. (Bidirectional and CrossFilter White Paper)


Variables (VAR) and the new INTERSECT, EXCEPT, and UNION functions will greatly simplify and sometimes improve performance of DAX code as well.