EXCEPT

The EXCEPT function returns rows from one table that are not found in another table.

Syntax

EXCEPT(
    table1,
    table2
)

Parameters
  • table1: DAX expression that returns a table, some of whose rows will be returned as a result of the function.
  • table2: DAX expression containing the rows to be excluded from the result of the function.
Returned value

The EXCEPT function returns a table.

Additional Information

table1 and table2 must have the same number of columns, and the table returned as a result of the function will have the same fields as them.

Examples

Suppose we have a table, Top sales countries, that contains the countries with total sales greater than a certain number:

Top sales countries = FILTER(
    SUMMARIZE(Geography, Geography[Country], "Sales", [Total sales]),
    [Total sales] > 3000000
)

EXCEPT function. Example of use

Now we want to know which countries are not in this table. For this we define the following measure:

Non top sales countries =
    VAR
        all_countries = SUMMARIZE(Geography, Geography[Country], "Sales", [Total sales])
    RETURN
        EXCEPT(all_countries, 'Top sales countries')

EXCEPT function. Example of use

Note how it was necessary to create a table, all_countries, with the same structure as the table whose rows we want to exclude from the result.

In this case it would have been easier to apply the SUMMARIZE and FILTER functions to directly obtain the countries with lower sales, but the way it has been done has let us apply the EXCEPT function, which was the objective.

Category
Other functions
Submitted by admin on Wed, 01/16/2019 - 14:13