CaseWhenMixed / Manipulation Layer

Create a new column using flexible conditional logic that supports both constant values and column references. Similar to a hybrid of SQL's CASE WHEN and pandas' np.select() with mixed literal and column values.

Common applications:

  • Data standardization (map values against reference tables)
  • Threshold-based classification (fixed bounds with dynamic values)
  • Quality scoring (compare against standards and peer values)
  • Alert generation (mix of absolute and relative triggers)
  • Business rules implementation (fixed and dynamic criteria)

Example: Product Pricing Strategy

ProductBase PriceCompetitor PriceStock LevelFinal Price
A1009520095
B15016050165
C20019010220
D120null150120

Implementation logic:

CASE 
  WHEN stock_level < 20 THEN base_price * 1.10             -- Constant multiplier
  WHEN competitor_price < base_price THEN competitor_price -- Column value
  WHEN stock_level > 100 THEN 'Standard'                   -- Constant text
  ELSE base_price                                          -- Column fallback
END

Key features:

  • Mix constant values and column references in conditions
  • Compare columns against fixed thresholds
  • Use both static and dynamic replacement values
  • Flexible type handling through AsDatatype
  • Configurable null value handling

Note: When mixing types, ensure compatibility and use AsDatatype appropriately for the desired output format.

Table
0
0
Table

CaseList

[, ...]

Defines a conditional case that can compare and replace with either constant values or column values. Enables flexible conditional logic combining fixed and dynamic data.

The column to evaluate in the condition. Forms the left side of the comparison. Example: price, quantity, rating

EqualTo

The operator to use for comparison

EqualTo ~

Equal.

NotEqualTo ~

Not equal.

LessThan ~

Less than.

LessThanOrEqualTo ~

Less than or equal.

GreaterThan ~

Greater than.

GreaterThanOrEqualTo ~

Greater than or equal.

StrContains ~

Contains.

StrDoesNotContain ~

Does not contain.

StrStartsWith ~

Begins with.

StrDoesNotStartWith ~

Does not begin with.

StrEndsWith ~

Ends with.

StrDoesNotEndWith ~

Does not end with.

CwValue

CwValue

string

Constant value to compare against. Examples:

  • Numeric threshold (100, 1000.0)
  • Status code ('ACTIVE')
  • Date ('2024-01-01') Must be compatible with SelectWhen column type

SelectCw

column

Column containing comparison values. Use when comparing against dynamic data like:

  • Historical values
  • Peer measurements
  • Reference standards Must be compatible with SelectWhen column type
RwValue

RwValue

string

Constant value to use when condition is true. Examples:

  • Standard category ('High', 'Low')
  • Default value (0, 100.0)
  • Status indicator ('Valid', 'Invalid') Will be converted to AsDatatype

SelectRw

column

Column containing replacement values. Use for dynamic results like:

  • Lookup values
  • Calculated fields
  • Alternative measurements Values will be converted to AsDatatype
FillNull

Specifies that when no conditions match, the resulting value should be null. This is a conservative approach to handling unmatched cases, making it explicit that no conditions were satisfied.

Default value to use when no conditions match. Similar to ELSE in SQL CASE statement. Provides a fallback value for unmatched cases. Example: 'Other', 'Unknown', -1

Column to draw default values from when no conditions match. Allows dynamic fallback values based on existing data. Useful for preserving original values in specific cases.

Name for the new column. If not provided, the system generates a unique name. If AsColumn matches an existing column, the existing column is replaced. The name should follow valid column naming conventions.

String

Specifies the output data type for the new column. Enables type control for the conditional results.

Int8 ~

8-bit signed integer (-128 to 127). For small-range discrete values.

Int16 ~

16-bit signed integer (-32,768 to 32,767). For moderate-range whole numbers.

Int32 ~

32-bit signed integer (-2^31 to 2^31-1). Common for general integer data.

Int64 ~

64-bit signed integer (-2^63 to 2^63-1). For large whole numbers.

Uint8 ~

8-bit unsigned integer (0 to 255). For small positive numbers.

Uint16 ~

16-bit unsigned integer (0 to 65,535). For moderate positive ranges.

Uint32 ~

32-bit unsigned integer (0 to 4,294,967,295). For larger positive numbers.

Uint64 ~

64-bit unsigned integer (0 to 2^64-1). For very large positive numbers.

Float32 ~

32-bit floating point. For decimal numbers with moderate precision.

Float64 ~

64-bit floating point. For high-precision decimal numbers.

String ~

Text data type. Default type for flexible value representation.

Categorical ~

Categorical string type. For efficient storage of repeated string values.

Bool ~

Boolean type. For true/false results.