Get error using "number(chosen(field))" inside a formula
Hi there,
I'm trying to use a field “Choice” (“Selección”, in Spanish) inside a formula, exactly like it's described here:
Without luck :-(
I have a field “Base” (a number, resulting of a SUM from 5 simple num fields)
Create a simple Choice (“Selección”) field (NOT Multiple Choice) and call it “Tipo Ret”. It contains two possible values, numbers: 0 and 15
Then I want to get a calculation from “Base” and “Tipo Ret” to get another “Retención” value.
This is: Base * Tipo Ret / 100
I use this formula, derived from the mentioned forum link:
Base * number(chosen('Tipo Ret')) / 100
But then I get an error “Function has not been defined: chosen(choice) Line 1 , Row 33” (in Spanish, really, see attached image)
And no matter how I try to adapt this formula and looking the rest of my DB I don't find where is the problem…
Attached is a image showing the switch interface, with a bad calculation result, because I originally used this other WRONG formula:
Base * number('Tipo Ret') / 100
Where is the problem with this other formula?:
Base * number(chosen('Tipo Ret')) / 100
NOTE: if I use a simple “Number” field to manually introduce “0” or “15” all calculations work fine…
THANKS!
Cristóbal Vila
2 replies
-
Per the manual, https://ninoxdb.de/en/manual/calculations/reference-of-functions-and-language
Type Conversion
Number Functionsnumber(value)
Tries to interpret the given value as a number.If value stems from a choice field, this will be the choice’s internal id. Use
number(text(choice))
to get a numeric representation of the choice’s text.Your formula should be...
Base * number(text('Tipo Ret')) / 100
The
chosen()
function is used for the Multiple Choice field. -
THANK YOU SOOOO MUCH, SEAN!
This is exactly what I was looking for. I was not expecting to receive an answer so quickly, in a weekend!
Very grateful :-)
Content aside
- 4 yrs agoLast active
- 2Replies
- 1316Views