Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

Matrix.IndexOfFirstValueMatching

Finds index of first value matching value.

Component Version macOS Windows Linux Server iOS SDK
Matrix 14.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "Matrix.IndexOfFirstValueMatching"; MatrixRef; Column; Operator; Value { ; StartRow } )   More

Parameters

Parameter Description Example Flags
MatrixRef The matrix reference number. $matrix
Column Which column to search. 0
Operator The compare operator.
Can be =, !=, <, >, <=, >=, ≤, ≥, ≠, Prefix or Postfix.
"≥"
Value The value to compare. "Test"
StartRow The row to start at.
Default is 0.
0 Optional

Result

Returns OK or error.

Description

Finds index of first value matching value.
This uses text or numeric comparison depending on the value in the matrix field.
Starting in the start row, we loop over all rows until the end and compare each value with the given operator to the value.

Examples

Try it:

Let([
matrix = MBS("Matrix.New"; 5; 5);
r = MBS( "Matrix.SetRow"; matrix; 0; "1¶3" );
r = MBS( "Matrix.SetRow"; matrix; 2; "123¶5" );
r = MBS( "Matrix.SetRow"; matrix; 3; "3¶4" );
index = MBS( "Matrix.IndexOfFirstValueMatching"; matrix; 0; "="; 123 )
]; index)

Example result: 2

Try prefix and postfix:

Let([
matrix = MBS("Matrix.New"; 5; 5);
r = MBS( "Matrix.SetRow"; matrix; 0; "1¶3" );
r = MBS( "Matrix.SetRow"; matrix; 2; "123¶5" );
r = MBS( "Matrix.SetRow"; matrix; 3; "Hello¶4" );
index1 = MBS( "Matrix.IndexOfFirstValueMatching"; matrix; 0; "prefix"; "He" );
index2 = MBS( "Matrix.IndexOfFirstValueMatching"; matrix; 0; "postfix"; "23" );
index3 = MBS( "Matrix.IndexOfFirstValueMatching"; matrix; 1; "="; "4" )
]; index1 & ¶ & index2 & ¶ & index3)

Example result:
3
2
3

See also

Release notes

Blog Entries

This function checks for a license.

Created 21st November 2023, last changed 22nd November 2023


Matrix.Height - Matrix.InsertRecords