MM_LEFTINNERJOIN and MM_RIGHTINNERJOIN functions

Join two ranges according to matching keys

Written By Nikolas Ethoré (Super Administrator)

Updated at November 24th, 2021

Description

The two functions return a table joining two ranges according to matching keys.

If a key from a range is not matching with a key from the other range, the line to join will not be displayed.

Syntax

=MM_LEFTINNERJOIN(Key1, Output1, Key2, Output2)
  • Key1: First range key

  • Output1: First range

  • Key2: Second range key

  • Output2: Second range to join with Output1

=MM_RIGHTINNERJOIN(Key1, Output1, Key2, Output2)
  • Key1: First range key

  • Output1: First range to join with Output2

  • Key2: Second range key

  • Output2: Second range

Remarks

  • Warning: For each line of your first range, the function matches keys only one time. Thus, if you have duplicates on any range key, the function does not make a full join as expected. So pay attention to not entering duplicates in your range key.

  • If the function can not match keys from a line, this line will not be displayed.

Example 1: LEFTINNERJOIN

Let us consider the two following tables:

You can see range keys at the first column of each table.

The formula to join those 2 tables according to their matching keys is the following:

=MM_LEFTINNERJOIN(B2:B4;C2:D4;G2:G5;H2:J5)

You can notice that the key "e" in Table 2 is not in key range of Table 1. Thus, the final line of Table 2 can not be joined. Same case with key "c" in Table 1.

This formula will return the following table, with, in the first place, elements from Table1, then elements from Table2:

Example 2: RIGHTINNERJOIN

With same inputs as in Example 1 (Table 1 and Table 2), the function MM_RIGHTINNERJOIN will join Table 1 with Table 2 with this following formula:

=MM_RIGHTINNERJOIN(B2:B4;C2:D4;G2:G5;H2:J5)

Here, the order will be différent, the formula will return the following table, with, in the first place, elements from Table 2, then elements from Table 1.

Example 3: Duplicates in range key

You can notice in the following picture that range key from Table 2 includes duplicates with key "b" appearing 2 times:

As explained in remarks, the function will take into account only the first key that matches with key from the first table.

Thus, the formula seen at Example 1 will return this following table:

You can notice that only the first occurence of key "b" is matched with key "b" from Table 1 here. The second occurence of key "b" is then ignored.