
Chapter 6: Fundamental Functions 201
Analysis
There are a lot of interesting things going on here. The Category and ProductName
slicers are cascading—the selection in the former dictates the products shown in
the latter. If you select a product first, it automatically selects the right category and
makes the category the first one in the Category slicer. You can control this behavior
in the Slicer Settings dialog. If you then select a different category, you end up with an
empty pivot table as there is no relationship between the product and an inappropriate
category—you have to remove the filter in the products slicer.
From a DAX perspective, the important change is the column parameter to the
ALL() function. The Category slicer alters the denominator; the ProductName slicer
does not. The SetFilter argument is saying, “implement all filters except those on
product name.” The user can select a product category and the figures in the pivot table
will be updated, both numerator and denominator. When the user selects a product,
only the numerator gets updated. This technique is handy for showing percentage
of parent. In 1997, Buchanan’s sales of Chai were about 8.9 percent of his sales of all
Beverages.
ALLEXCEPT() 1/2
The ALLEXCEPT() function is another function that returns a table and can be used
as a SetFilter argument for the CALCULATE() function. Its own parameters are a
table name followed by one or more column names. Before we look at ALLEXCEPT(),
here are three formulas for a numerator, denominator, and a numerator divided by a
denominator.
ALLEXCEPT() is a Filter function. The examples are measures. Your figures may
differ if you have a different release of Northwind from the one used here.
Syntax
=SUM('Order Details'[Sales Amount])
=CALCULATE(SUM('Order Details'[Sales Amount]))
=SUM('Order Details'[Sales Amount])/
CALCULATE(SUM('Order Details'[Sales Amount]))