NATURALLEFTOUTERJOIN

The NATURALLEFTOUTERJOIN function performs a natural left outer join of two tables.

Syntax

NATURALLEFTOUTERJOIN(
    leftJoinTable,
    rightJoinTable
)

Parameters
  • leftJoinTable: Existing table or expression that returns a table for the left side of the join.
  • rightJoinTable: Existing table or expression that returns a table for the right side of the join.
Returned value

The NATURALLEFTOUTERJOIN function returns the left table after adding the non-common columns of the right table using the values of the common fields in both tables as keys.

Additional Information

The resulting table will have the columns from the left table plus the uncommon columns from the right table.

The order of the rows in the result table is not guaranteed.

Common columns must have the same data type in both tables.

Only columns with the same lineage (from the same source) are combined.

Examples

Suppose we start from the following two tables, "Population":

NATURALINNERJOIN function. Example of use

and "Extension":

NATURALINNERJOIN function. Example of use

...containing respectively the population and extension of a certain number of countries.

We can try to perform a left outer join between these two tables with the following expression:

naturalleftouterjoin = NATURALLEFTOUTERJOIN(Extension, Population)

NATURALLEFTOUTERJOIN function. Example of use

...but we see how it returns an error message due to a bug when working with this type of combination.

A possible solution is to read the tables using the SELECTCOLUMNS function, adding an empty text string to the common fields:

naturalleftouterjoin =
    VAR
        LeftTable =
            SELECTCOLUMNS(
                Population,
                "Country", Population[Country] & "",
                "Population", Population[Population]
        )
    VAR
        RightTable =
            SELECTCOLUMNS(
                Extension,
                "Country", Extension[Country] & "",
                "Extension", Extension[Extension]
            )
    RETURN
        NATURALLEFTOUTERJOIN(LeftTable, RightTable)

NATURALLEFTOUTERJOIN function. Example of use
Related functions
Category
Other functions
Submitted by admin on Thu, 01/17/2019 - 13:07