Matrix.Evaluate
---------------

Evaluates an expression for each cell.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Matrix](component_Matrix.md) | [10.2](newinversion102.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Matrix.Evaluate"; MatrixRef; Expression { ; FirstRow; LastRow; firstCol; lastCol; Flags } ) 

**MBS**( **"Matrix.Evaluate";** /\* Evaluates an expression for each cell. \*/  
**$MatrixRef**; /\* The matrix reference number.e.g. $matrix \*/   
**$Expression**; /\* The expression to evaluate.  
Can include "row", "column" and "current" as variables.e.g. "current +1" \*/   
**$FirstRow**; /\* Optional; The index of first row.  
Default is 0.e.g. 0 \*/   
**$LastRow**; /\* Optional; The index of last row.  
Default is [Matrix.Height](MatrixHeight.md)-1.e.g. 5 \*/   
**$firstCol**; /\* Optional; The index of first column.  
Default is 0.e.g. 0 \*/   
**$lastCol**; /\* Optional; The index of last column.  
Default is [Matrix.Width](MatrixWidth.md)-1.e.g. 6 \*/   
**$Flags**) /\* Optional; Pass 1 to ignore results of expressions and not put them back in matrix.  
Pass 2 to continue after error (new in 13.5).e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| MatrixRef | The matrix reference number. | $matrix |  |
| Expression | The expression to evaluate.   Can include "row", "column" and "current" as variables. | "current +1" |  |
| FirstRow | The index of first row.   Default is 0. | 0 | Optional |
| LastRow | The index of last row.   Default is [Matrix.Height](MatrixHeight.md)-1. | 5 | Optional |
| firstCol | The index of first column.   Default is 0. | 0 | Optional |
| lastCol | The index of last column.   Default is [Matrix.Width](MatrixWidth.md)-1. | 6 | Optional |
| Flags | Pass 1 to ignore results of expressions and not put them back in matrix.   Pass 2 to continue after error (new in 13.5). | 0 | Optional |

### Result

Returns OK or error.

### Description

Evaluates an expression for each cell.  
You can change the value by doing a calculation in FileMaker syntax to change the value.  
Reference current value via "current", the current row via "row" and the current column via "column" as variable names.  
The result of the evaluate is written to the cell.  
May return error if expression is invalid.   
### Examples

Try evaluate:

 Set Variable \[ $matrix ; Value: MBS ("[Matrix.New](MatrixNew.md)"; 5; 6) \]   
\# set values   
Set Variable \[ $r ; Value: MBS ("[Matrix.SetRow](MatrixSetRow.md)"; $matrix ; 0; "Joe¶Miller¶New York¶123") \]   
Set Variable \[ $r ; Value: MBS ("[Matrix.SetRow](MatrixSetRow.md)"; $matrix ; 1; "Bob¶Jones¶Washington¶234") \]   
Set Variable \[ $r ; Value: MBS ("[Matrix.SetRow](MatrixSetRow.md)"; $matrix ; 2; "Jane¶Stones¶Los Angeles¶567") \]   
  
\# add one to all by expression   
Set Variable \[ $r ; Value: MBS ("Matrix.Evaluate"; $matrix ; "current + 1"; 0; 2; 3; 3) \]   
  
\# show numbers   
Show Custom Dialog \[ "Values" ; MBS ("[Matrix.GetColumn](MatrixGetColumn.md)"; $matrix ; 3) \]   
Set Variable \[ $r ; Value: MBS ("[Matrix.Release](MatrixRelease.md)"; $matrix ) \]  
Set each cell to the value and row/column:

 Set Variable \[ $r ; Value: MBS ("Matrix.Evaluate"; $matrix ; "current &amp; \\" \\" &amp; row &amp; \\" \\" &amp; column"; 0; 3; 3; 3) \]  
Continue on error 500 (bad date format) and remove invalid dates:

 Let(\[  
  
m = MBS ("[Matrix.New](MatrixNew.md)"; 7; 2);  
s = MBS ("[Matrix.SetColumn](MatrixSetColumn.md)"; m; 0; "10/23/71¶5.4 .68¶16.555555 ¶garbage¶4-8-2003¶50/3/2356¶5.4 .68" );  
s = MBS ("[Matrix.SetColumn](MatrixSetColumn.md)"; m; 1; "10/23/71¶5.4 .68¶16.555555 ¶garbage¶4-8-2003¶50/3/2356¶5.4 .68" );  
e = "if ( GetAsText(GetAsDate ( current )) = \\"?\\" ; \\"\\" ; GetAsDate ( current ) )";   
s = MBS ("Matrix.Evaluate"; m; e; 1; 6; 1; 1; 2);  
  
r = MBS ("[Matrix.Text](MatrixText.md)"; m; ""; ""; ""; ""; ""; " =&gt; ")  
\];r)  
<small>  
Example result:   
10/23/71 =&gt; 10/23/71  
5.4.68 =&gt; 05.04.1968  
16.555555 =&gt;   
garbage =&gt;   
4-8-2003 =&gt; 04-08-2003  
50/3/2356 =&gt;   
5.4.68 =&gt; 05.04.1968</small>Try to sum up a column:

 # make new matrix   
Set Variable \[ $m ; Value: MBS ("[Matrix.New](MatrixNew.md)"; 7; 3) \]  
  
\# fill in a few values   
Set Variable \[ $r ; Value: MBS ("[Matrix.SetColumn](MatrixSetColumn.md)"; $m ; 0; "1¶2¶3¶4¶5¶6¶7" ) \]  
Set Variable \[ $r ; Value: MBS ("[Matrix.SetColumn](MatrixSetColumn.md)"; $m ; 1; "1¶2¶3¶4¶5¶6¶7" ) \]  
  
\# now sum first and second column to go in the third column   
Set Variable \[ $r ; Value: MBS ("Matrix.Evaluate"; $m ; "MBS ( \\"[Matrix.GetValue](MatrixGetValue.md)\\"; $m ; Row; 0 ) + MBS ( \\"[Matrix.GetValue](MatrixGetValue.md)\\"; $m ; Row; 1 )"; 0; MBS ("[Matrix.Height](MatrixHeight.md)"; $m )-1; 2; 2) \]  
  
\# output as CSV   
Set Variable \[ $r ; Value: MBS ( "[Matrix.CSV](MatrixCSV.md)"; $m ) \]  
### See also

- [Matrix.CSV](MatrixCSV.md)
- [Matrix.GetColumn](MatrixGetColumn.md)
- [Matrix.GetValue](MatrixGetValue.md)
- [Matrix.Height](MatrixHeight.md)
- [Matrix.New](MatrixNew.md)
- [Matrix.Release](MatrixRelease.md)
- [Matrix.SetColumn](MatrixSetColumn.md)
- [Matrix.SetRow](MatrixSetRow.md)
- [Matrix.Text](MatrixText.md)
- [Matrix.Width](MatrixWidth.md)

### Release notes

- **Version 13.5**
    - Added Flags Parmeter for [Matrix.Evaluate](https://www.mbsplugins.eu/MatrixEvaluate.shtml). Pass 2 to continue after error.
    - Improved [Matrix.Evaluate](https://www.mbsplugins.eu/MatrixEvaluate.shtml) and Matrix.Current to work better in multi threading environments.
- **Version 11.1**
    - Fixed parameters for [Matrix.Evaluate](https://www.mbsplugins.eu/MatrixEvaluate.shtml) function.
- **Version 10.2**
    - Added [Matrix.Evaluate](https://www.mbsplugins.eu/MatrixEvaluate.shtml) function.

### Blog Entries

- [MBS FileMaker Plugin, version 13.5pr1](https://www.mbsplugins.de/archive/2023-09-26/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 11.1pr1](https://www.mbsplugins.de/archive/2021-02-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [News about the MBS FileMaker Plugin 10.2](https://www.mbsplugins.de/archive/2020-05-19/News_about_the_MBS_FileMaker_P/monkeybreadsoftware_blog_filemaker)
- [Neues MBS FileMaker Plugin 10.2](https://www.mbsplugins.de/archive/2020-05-12/Neues_MBS_FileMaker_Plugin_102/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 10.2 - More than 6200 Functions In One Plugin](https://www.mbsplugins.de/archive/2020-05-12/MBS_FileMaker_Plugin_102_-_Mor/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 10.2pr2](https://www.mbsplugins.de/archive/2020-04-06/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 2nd April 2020 , last changed 25th February 2026

  
[Matrix.DataType](MatrixDataType.md) - [Matrix.GetColumn](MatrixGetColumn.md)

[HTML Version](MatrixEvaluate.shtml)