I would like to know how to get computed field in MS Access that shows maximum of a number or zero. I mean the function that is similar to the one in Excel Max(A1,0)
. How do I get this in Access expression builder?
CodePudding user response:
I suppose the only problem you could face, is that if the field has a null value. To be safe, wrap the field with the Nz() function which replaces null to the given argument.
Max(Nz([YourFieldName],0))
When the field is numeric, the zero can be omitted.
Max(Nz([YourFieldName]))
CodePudding user response:
You want "the function that is similar to the one in Excel Max(A1,0)
". That specific expression evaluates only 2 values: whatever value is in cell A1; and zero.
So I think you want an expression for your computed field which yields results similar to this ...
YourField | Desired Result |
---|---|
1 | 1 |
-1 | 0 |
0 | 0 |
You can do that in an Access query with an IIf
expression ...
SELECT IIf(YourField > 0, YourField, 0)
FROM YourTable;