Get value of cascading select list for calculation

Issue #691 resolved
Nadine created an issue

Hello Fidel I have a cascading select list with locations on the first level and an hourly labour rate on the second level, so it's 1:1 between first an second level (this is not the most sophisticated way of storing the dependency between location an hourly labour rate but I only need to build a prototype at the moment :)). I have another calculated field where a sum of labour hours is stored. Now I want to set up a calculated field labour cost for the product of hourly labour rate * sum of labour hours. What is the correct expression to refer to the hourly labour rate stored on the second level of my cascading select list field? Many thanks for your advice.

Comments (5)

  1. Fidel Castro Armario repo owner

    Hi @naschuett,

    Use the following expression:

    toNumber(%{aaaaa.1}) * {bbbbb}
    

    replacing aaaaa with field code for your Cascading Select custom field, and bbbbb with field code for Sum of labour hours calculated field, which I'm assuming it's a Calculated Number Field.

  2. Nadine Account Deactivated reporter

    Hello Fidel

    many thanks for your quick response.

    Indeed, what you suggest is what I had already tried but it did not work. I checked the log and the following error is displayed: Error: null value at left hand side operand in arithmetic multiplication operation.

    So, I guess something must be wrong with my cascading select. It has the following formats (0: and 1: indicating the levels):

    • 0: HAM 1: 91,50
    • 0: FRA 1: 95,00
    • 0: BER 1:89,00 ...

    I tried with the expression you provided

    toNumber(%{HourlyRate.1}) * {Effort (FY) PM}
    

    and, since I had seen some advice of yours in the issues,

    toNumber(%{HourlyRate.01}) * {Effort (FY) PM} 
    

    What am I not getting right?

  3. Fidel Castro Armario repo owner

    Use the following formula instead:

    toNumber(replaceAll(%{aaaaa.1}, ",", ".")) * {bbbbb}
    
  4. Nadine Account Deactivated reporter

    Amazing, that works, thanks a lot :)

    Is there any documentation apart from yours which I can refer to to understand this kind of expressions rather than logging further tickets here?

  5. Log in to comment