DAX Union and Intersect Function

Shristi
3 min readDec 20, 2019

--

DAX Information functions look at the value or column that is provided as an argument and tell you whether the value matches the expected type.

UNION

It is used to combine a pair of tables.

A table that contains all the rows from each of the two table expressions.

The two tables must have the same number of columns.

Columns are combined by position in their respective tables.

The column names in the return table will match the column names in table_name1.

Duplicate rows are retained.

Returns the row intersection of two tables, retaining the duplicates.

Syntax

UNION(<table_name1>, <table_name2> [,<table_namen>]…)

Example

In the following example, there are two tables are involved Employee and New_Emp

New_Emp table
Employee table

Go to the Modeling tab and add New table

Rename the table and following and Add the following Statement

AllEmp = UNION(Employee,New_Emp)

As shown above, both the tables Employee and New_Emp are combined

INTERSECT

  • Intersect is not commutative. That means Intersect (T1, T2) can have a different result set than Intersect (T2, T1).
  • Duplicate rows are retained. That means, if a row appears in table_name1 and table_name2, it and all duplicates in table_name1 are included in the result set.
  • The column names will match the column names in table_name1.
  • Columns are compared based on the positioning, and data comparison with no type coercion.
  • The returned table does not include columns from the tables related to table_name1.

Syntax

INTERSECT (<table_name1>, <table_name2>)

Example

In the following example, there are two tables are involved Employee and New_Emp

New_Emp table
Employee table

Add a new table and rename it to Intersect_emp

Add this statement this in the bar

The above statement returns common data in both table

Intersect_Emp= Intersect_Emp = INTERSECT(Employee,New_Emp)

Both tables have the following data in common

--

--

No responses yet