Home Search

DriveWorks Pro 23
TableFilterByFunction

Send Feedback

TableFilterByFunction

Filters a table of data or array based on a single column using the provided Lambda Function.

Syntax

TableFilterByFunction(Input Array, Column Index, Filter Function, [Include Header Row])

Where:

Input Array is the array to iterate over.

Column Index is the column to check for a match.

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, FALSE (default) to exclude.

  • 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(value, [rowIndex], Function)

value is the value in the specified column of the original table to be evaluated.

  • When the Input Array is parsed, the value from each row of the specified column is passed to the function.
  • value 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 rowIndex 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 match found in the given column.

Rule

TableFilterByFunction(
	DwLookupBeamSizes, 
	4, 
	DWLambda(
		value, 
		value>11
		)
	,FALSE 
)

Result

The result is a new array that only includes rows where values in column 4 are greater than 11.

Viewed as an array:

{"Size","Height","Depth","Width";"W27 x 178","27.8","0.725","14.1";"W27 x 161","27.8","0.66","14";"W24 x 162","24.6","0.695","12.1";"W24 x 146","24.6","0.68","12"}

Viewed as a table:

SizeHeightDepthWidth
W27 x 17827.80.72514.1
W27 x 16127.80.6614
W24 x 16224.60.69512.1
W24 x 14624.60.6812

Data (Table named BeamSizes)

The original table containing the array to be filtered.

SizeHeightDepthWidth
W27 x 17827.80.72514.1
W27 x 16127.80.6614
W27 x 11427.30.5710.1
W27 x 10227.10.51510
W24 x 16224.60.69512.1
W24 x 14624.60.6812
W21 x 14722.10.5911
W21 x 9321.60.489.5
W21 x 8321.40.479
W21 x 57210.388
W21 x 50210.387

Example 2

This example filters a table based on a match found in the given column and conditionally excludes the given row.

Rule

TableFilterByFunction(
	DwLookupBeamSizes,
	4, 
	DWLambda(
		value, 
		rowIndex,
		If(
			rowIndex=2,
			FALSE, 
			value>10
			)
		),FALSE
	)

Result

The result is a new array that only includes rows where values in column 4 are greater than 10 and excludes the row with index 2.

Viewed as an array:

{"Size","Height","Depth","Width";"W27 x 178","27.8","0.725","14.1";"W27 x 161","27.8","0.66","14";"W24 x 162","24.6","0.695","12.1";"W24 x 146","24.6","0.68","12";"W21 x 147","22.1","0.59","11"}

Viewed as a table:

SizeHeightDepthWidth
W27 x 17827.80.72514.1
W27 x 11427.30.5710.1
W24 x 16224.60.69512.1
W24 x 14624.60.6812
W21 x 14722.10.5911

Data (Table named BeamSizes)

The original table containing the array to be filtered.

The row with index 2, omitted by the rule, has been highlighted.

SizeHeightDepthWidth
W27 x 17827.80.72514.1
W27 x 16127.80.6614
W27 x 11427.30.5710.1
W27 x 10227.10.51510
W24 x 16224.60.69512.1
W24 x 14624.60.6812
W21 x 14722.10.5911
W21 x 9321.60.489.5
W21 x 8321.40.479
W21 x 57210.388
W21 x 50210.387

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.

TableFilterByRowFunction - Filters an array using the provided Lambda Function applied to each row.