How to Use the MMULT Function in Google Sheets

Published on

You can use the MMULT function for matrix multiplication in Google Sheets. It might sound complex, but here’s a simple explanation:

Assume you have two tables: one is a price list, and the other is sales data for the items specified in the price list. We can call the first table Matrix A and the second table Matrix B.

Matrix A (Only the Numbers)

AppleOrangeMango
Price$4.50$4.00$3.75

Matrix B (Only the Numbers)

Quantity
Apple5
Orange10
Mango5

How do you find the total sales amount of these items?

You would probably use =4.50 * 5 + 4.00 * 10 + 3.75 * 5, and the result would be $81.25.

This process is called matrix multiplication, which essentially combines two grids of numbers to create a new result, following a specific set of rules.

It’s an error-prone and time-consuming task. We can automate this using the MMULT function in Google Sheets.

When performing matrix multiplication, ensure that the number of columns in Matrix A equals the number of rows in Matrix B.

In the example above, Matrix A has three columns, and Matrix B has three rows.

MMULT Function: Syntax and Arguments

Syntax:

MMULT(matrix1, matrix2)

Arguments:

  • matrix1 – The first array or range to be used in the matrix multiplication operation.
  • matrix2 – The second array or range to be used in the matrix multiplication operation.

Below are three carefully chosen examples of using the MMULT function in Google Sheets.

Example 1: Matrix 1 with 3 Columns (1×3 Matrix) and Matrix 2 with 3 Rows (3×1 Matrix)

MMULT Formula Example 1: 1x3 Matrix and 3x1 Matrix

Assume Matrix 1 is in B2:D2 (prices of fruits), and Matrix 2 (quantities of fruits) is in B6:B8.

You can use the following MMULT formula to calculate the matrix product, which will be 81.25, representing the total price of the fruits:

=MMULT(B2:D2, B6:B8)

Example 2: Matrix 1 with 3 Columns (1×3 Matrix) and Matrix 2 with 3 Rows (3×5 Matrix)

MMULT Formula Example 1: 1x3 Matrix and 3x5 Matrix

This time, Matrix 2 contains five columns representing sales quantities for each workday from Monday to Friday.

Matrix 1 (prices) is in the range B2:D2, and Matrix 2 (sales quantities) is in the range B6:F8.

The number of columns in Matrix 1 is 3, and the number of rows in Matrix 2 is also 3, satisfying the matrix multiplication rule.

To calculate the total sales amount for each workday, use the following MMULT formula:

=MMULT(B2:D2, B6:F8)

Example 3: Matrix 1 with 3 Columns (2×3 Matrix) and Matrix 2 with 3 Rows (3×5 Matrix)

MMULT Formula Example 1: 2x3 Matrix and 3x5 Matrix

In this example, the prices are in two rows: B2:D2 contains the old prices, and B3:D3 contains the revised prices. Therefore, Matrix 1 is in the range B2:D3, making it a 2×3 matrix.

Matrix 2 is the same as in the previous example, with sales quantities in 5 columns in the range B6:F8.

The number of columns in Matrix 1 is 3, and the number of rows in Matrix 2 is also 3, satisfying the matrix multiplication rule.

To calculate the total sales amount for each workday based on old and revised prices separately, use the following MMULT formula:

=MMULT(B2:D3, B6:F8)

I hope these examples clarify the practical use of the MMULT function in Google Sheets.

Common Errors

When using the MMULT function, you might encounter the #VALUE! error. If you do, hover your mouse pointer over the error to read the tooltip.

  • If it says “MMULT has incompatible matrix sizes,” it means the matrices are not following the matrix multiplication rule.
  • If it says “Function MMULT parameters expect number values,” make sure there are no empty cells or text in the range. If there are empty cells or text, and you need to keep them in the range, you can use the following workaround:

Wrap the matrices with the N function and enter the formula as an array formula.

Example:

=ArrayFormula(MMULT(N(B2:D3), N(B6:F8)))

This will convert non-numeric values to 0s and resolve the issue.

Resources

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Expert Prashanth KV is a Diamond Product Expert in Google Sheets, officially recognized by Google for his contributions to the Docs Editors Help Community and featured in the Google Product Experts Directory. With years of experience working with Google Sheets and Excel for multinational firms in Mumbai and Dubai, he has been blogging since 2012, offering practical, real-world spreadsheet solutions that professionals rely on. Explore his blog to learn advanced formulas, automation tips, and problem-solving techniques to elevate your spreadsheet skills.

Mode of Comma-Separated Numbers in Excel (Dynamic Array)

There is no dedicated function in Excel to directly find the mode of comma-separated...

How to Find Mode of Comma-Separated Numbers in Google Sheets

Working with comma-separated numbers inside a single cell is a common scenario in Google...

How to Count Merged Cells in Google Sheets (and Get Their Size)

Sometimes, you may have blocks of merged cells in a column or row. But...

Count Consecutive Workday Absences in Google Sheets

This tutorial offers a powerful formula-based solution to count consecutive workday absences in Google...

More like this

How to Find Mode of Comma-Separated Numbers in Google Sheets

Working with comma-separated numbers inside a single cell is a common scenario in Google...

How to Count Merged Cells in Google Sheets (and Get Their Size)

Sometimes, you may have blocks of merged cells in a column or row. But...

Count Consecutive Workday Absences in Google Sheets

This tutorial offers a powerful formula-based solution to count consecutive workday absences in Google...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.