Home Search

DriveWorks Pro 23
TableFilterByRowFunction

Send Feedback

TableFilterByRowFunction

Filters a table of data or array using the provided Lambda Function applied to each row.

Syntax

TableFilterByRowFunction(Input Array, Filter Function, [Include Header Row])

Where:

Input Array is the array to iterate over.

Filter Function if the result of this function is TRUE, it will be included in the result.

Include Header Row (optional) if true, the header will be included in the filter.

  • Input Arrays are assumed to include a header row by default. Set this argument to TRUE if the Input Array does not have a header row.

Filter Function

Please see Higher Order Functions for more information on this type of function.

The DWLambda used for the filter function uses the following syntax:

DWLambda(dataRow, [rowIndex], Function)

dataRow is the row from the Input Array to be evaluated.

  • When the Input Array is parsed each dataRow is passed to the function.
  • dataRow is a required parameter in the Function Argument.

rowIndex (optional) is the index of the row currently being evaluated.

  • When the Input Array is parsed the index of each row is passed to the function.
  • Using the dataRow in the Function argument is optional.
  • The Filter Function will not retrieve values from the header row. A rowIndex of 1 will refer to the first data row, which is the first row after the header row or the first row in a table with no headers (in which case Include Header Row must be set to TRUE).

Function is the Lambda function to be executed.

Use Rules Insight to insert the required lambda signature into the function.

Examples

Example 1

This example filters a table based on a comparison of values found in two cells of each row.

Rule

TableFilterByRowFunction(
	DwLookupBeamSizesSy, 
		DWLambda(
			dataRow, 
			TableGetValue(dataRow,3,1)*100<TableGetValue(dataRow,2,1)
		)
	,FALSE
)

Result

The result is a new array that only includes rows where the value in cell 3, multiplied by 100, is less than the value in cell 2.

Viewed as an array:

{"Size","Sy","WT","W";"W27 x 178","78.8","0.725","14.1";"W27 x 146","63.5","0.605","14";"W21 x 147","60.1","0.59","11";"W21 x 101","51.2","0.5","9.5"}

Viewed as a table:

SizeSyWTW
W27 x 17878.80.72514.1
W27 x 14663.50.60514
W21 x 14760.10.5911
W21 x 10151.20.59.5

Data (Table named BeamSizesSy)

The original table containing the array to be filtered.

SizeSyWTW
W27 x 17878.80.72514.1
W27 x 16165.90.6614
W27 x 14663.50.60514
W27 x 11431.50.5710.1
W24 x 558.30.4410
W21 x 14760.10.5911
W21 x 13253.50.5811
W21 x 10151.20.59.5
W21 x 9322.10.489.5
W21 x 8319.50.479
W21 x 579.40.388

Example 2

This example filters a table based on a comparison of values found in two cells of each row, and conditionally include a given row.

Rule

TableFilterByRowFunction(
	DwLookupBeamSizesSy, 
	DWLambda(
		dataRow, 
		rowIndex, 
		If(
			rowIndex=11,
			TRUE, 
			TableGetValue(dataRow,3,1)*100<TableGetValue(dataRow,2,1)
			)
		),FALSE
	)

Result

The result is a new array that only includes rows where the value in cell 3, multiplied by 100, is less than the value in cell 2. Row 11 is included regardless of this match.

Viewed as an array:

{"Size","Sy","WT","W";"W27 x 178","78.8","0.725","14.1";"W27 x 146","63.5","0.605","14";"W21 x 147","60.1","0.59","11";"W21 x 101","51.2","0.5","9.5";"W21 x 57","9.4","0.38","8"}

Viewed as a table:

SizeSyWTW
W27 x 17878.80.72514.1
W27 x 14663.50.60514
W21 x 14760.10.5911
W21 x 10151.20.59.5
W21 x 579.40.388

Data (Table named BeamSizesSy)

The original table containing the array to be filtered.

The row with index 11, included by the rule, has been highlighted.

SizeSyWTW
W27 x 17878.80.72514.1
W27 x 16165.90.6614
W27 x 14663.50.60514
W27 x 11431.50.5710.1
W24 x 558.30.4410
W21 x 14760.10.5911
W21 x 13253.50.5811
W21 x 10151.20.59.5
W21 x 9322.10.489.5
W21 x 8319.50.479
W21 x 579.40.388

See Also

Higher Order Functions - About higher order functions.

DWLambda - Allows custom, reusable functions to be created.

TableMap - Applies a Lambda Function across a provided array and returns a new array with the result of the Lambda function applied.

TableFilterByFunction - Filters an array based on a single column using the provided Lambda Function.