0

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:

https://ninoxdb.de/en/forum/technical-help-5ab8fe445fe2b42b7dd39ee7/calculation-based-on-multiple-choice-5ad242c2b65c652c6b59b1d8

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

A

 

B

 

C

 

D

2 replies

null
    • Sean
    • 4 yrs ago
    • Reported - view

    Per the manual, https://ninoxdb.de/en/manual/calculations/reference-of-functions-and-language

     

    Type Conversion
    Number Functions
    number(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.

    • Etérea Estudios
    • Cristobal
    • 4 yrs ago
    • Reported - view

    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
  • 1302Views