0

We have a seasonal service product that runs over the course of eight weeks in summer. There's a minimum of two weeks use. You have to start on Monday and finish on a Friday. With that in mind, I created a drop-down menu to choose a start date. Then one of seven drop-downs appears with finish date options. IF logic used to display each one.

At the end of that, I wanted a calculation to pick out the Amount for each no matter which start/end date there was. So another IF statement:

=(if StartDate = "27 June 2016" THEN EndDate0_Amount ELSE "")+
 (if StartDate = "4 July 2016" THEN EndDate1_Amount ELSE "")+
 (if StartDate = "11 July 2016" THEN EndDate2_Amount ELSE "")

Field name: Costpreconv

This gives the correct amount as in Text format (amount dictated as numerical/currency amount using Cognito functionality).

However, whenever I try to parse that to a decimal or currency it's not working.

=Decimal.Parse(Costpreconv) Returns nothing at all

And if I don't use Decimal.Parse, it says

'The expected type of this field is 'Decimal' at character 0'

0

Since this question is about a specific form in Cognito Forms, your best bet is to submit a support request:

https://www.cognitoforms.com/support

However, in this case, you likely just need to specify that the field, Costpreconv, be of type Currency. This way you will not need to then attempt to convert a text value into a numeric value.

=(if StartDate = "27 June 2016" THEN EndDate0_Amount ELSE "") +
 (if StartDate = "4 July 2016" THEN EndDate1_Amount ELSE "") +
 (if StartDate = "11 July 2016" THEN EndDate2_Amount ELSE "")

More than likely, the reason your current approach is not working is the value includes currency information like $. Changing the calculation field to the appropriate type will still show the value with currency formatting, but the underlying value will be numeric and work correct in calculations.

  • I thought it might be happening to others as well so could have been worth posting here. I've tried Costpreconv being both decimal and currency to no avail. – user3653017 Apr 27 '16 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.