# Equation - Multiply two fields

3 years 10 months ago #134072
Morning Guys,

Been scratching my head over this for last couple of days and cant work out exactly how to do it. Been looking at relevance equations and can't seem to work it out.
Basically, I want an equation field or a display text field question type to display an amount of two previous numerical input fields multiplied together (which also write back to the db).

E.g
Q1. Fence Type (dropdown box) subquestion 1 is selected
Q2. Linear Metres: 5 is input (Numerical input - static)
Q3. Unit cost: £9.99 (amount automatically displayed in dropdown to be selected based on condition with Q1)
Q4. The total net cost: ((Q2)*Q3A1 or Q3A2 or Q3A3) - This is the part I cant figure out, as you can see there are OR operators in this equation if a different unit cost and fence type had been selected)

I hope I explained this well enough and someone can point me in the right direction

Much appreciated
Stephen

LimeSurvey Partners
3 years 10 months ago #134082 by tpartner
You can use hidden equation type questions to store the unit and total costs.

- Q1 - "Fence Type" (dropdown box)

- Q2 - "Linear Metres": (numerical input)

- equation1 - (equation question) - stores the unit cost with an equation using nested IF statements like this (line-breaks added for clarity)
```{if(Q1 == 'A1', '9.99',
if(Q1 == 'A2', '10.99',
if(Q1 == 'A3', '11.99',
if(Q1 == 'A4', '12.99', '')
)
)
)}```

- equation2 - (equation question) - stores the total cost with an equation like this:
`{equation1 * Q2}`

- display1 - "The total net cost: {equation2}"

Sample survey attached:

#### File Attachment:

File Name: limesurvey...9-10.lss
File Size:16 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com
##### Attachments:
The following user(s) said Thank You: stemate1988