--- title: "MAX(MIN(A,B),C)" slug: "dmathfunction-16" updated: 2021-11-03T11:40:24Z published: 2021-11-03T11:40:24Z canonical: "docs.datajet.app/dmathfunction-16" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.datajet.app/llms.txt > Use this file to discover all available pages before exploring further. # MAX(MIN(A,B),C) ## DMath: MAX(MIN(A,B),C) ## Calculates the minimum of (A or B) then returns the maximum of the selected value or C ## Purpose Use this function to: - Compare value C to whichever is lower out of A or B - First find the minimum of 2 values, and then compare that minimum with a third value to find the maximum ## Return Value | Property | Value | | --- | --- | | **FieldType** | Double | | **FieldSize** | Low / Med / High / Continuous | | **DataType** | Discrete / Continuous | | **DataSize** | Short / Integer / LongInteger / Double | ```shell Example Return Value: X*.XXXXXX....-X*.XXXXX e.g. 21.000000, 98754654.123456, -5.000000, -654.320000 ``` ![](https://cdn.document360.io/73b6469b-c1e4-47e9-aa65-986c8ebd17ca/Images/Documentation/DMATH_MAXOFMINAB_Sample.PNG) ## Parameters | Parameter | JSON | Description | | --- | --- | --- | | **Table** | “targetTable”: “MyTableName” | The target table on which the new field will be created | | **Filter** | “dataset”: {DataSet_JSON} | Optional. If a filter is applied, records not in the filter recordset will be returned as null. | | **Math** **Function** | “p1”: “Max(Min(A,B),C)” | Max(Min(A,B),C) | | **A** | “p2”: “NumericFieldName” “p2”: “#N*.N*” | Required. Numerical input for A. Compared with B to select minimum. *Supports:* - **DataType:** Discrete / Continuous - **Field Type:** Integer, Double - **Fixed Value:** #N* e.g. #201596, #-87 - **Fixed Value:** #N*.N* e.g. #201596.05, #-87.98 | | **B** | “p3”: “NumericFieldName” “p3”: “#N*.N*” | Required. Numerical input for B. Compared with A to select minimum. *Supports:* - **DataType:** Discrete / Continuous - **Field Type:** Integer, Double - **Fixed Value:** #N* e.g. #201596, #-87 - **Fixed Value:** #N*.N* e.g. #201596.05, #-87.98 | | **C** | “p4”: “NumericFieldName” “p4”: “#N*.N*” | Required. Numerical input for C. Compared with whichever is the minimum of A or B to select maximum. *Supports:* - **DataType:** Discrete / Continuous - **Field Type:** Integer, Double - **Fixed Value:** #N* e.g. #201596, #-87 - **Fixed Value:** #N*.N* e.g. #201596.05, #-87.98 | | **Treat Null as Zero** | "nullIsZero": true "nullIsZero": false | True/False. Default = False If true, then any null values in the input fields will be treated as if they have a value of 0. If false, then if any of A, B or C is Null, then a Null will be returned. | ## JSON Sample ![](https://cdn.document360.io/73b6469b-c1e4-47e9-aa65-986c8ebd17ca/Images/Documentation/DMATH_MAXOFMINAB_JSON.PNG) ## Usage Notes See Also: - [DMATH Overview](https://datajet.document360.io/docs/dmathfunction-1) - Mathematical Expression Field - MAX(A,B)   (DMATH) - MIN(A,B)    (DMATH) - MAX(MIN(A,B),C)  (LMATH) ## Example | Example | Details | | --- | --- | | **Description** | Maximum of input C and whichever is the lower of A or B | | **Input** | - Table: = [customer] - Filter: = [No Filter] - Function: = DMath - **Math Function** **= MAX(MIN(A,B),C)** - A:= [customer ].[Input_A] - B:= [customer ].[Input_B] - C:= [customer ].[Input_C] - Name: = MaxMinABC | | **Sample** | ![](https://cdn.document360.io/73b6469b-c1e4-47e9-aa65-986c8ebd17ca/Images/Documentation/DMATH_MAXOFMINAB_Example.PNG) |