Add Specific Values If One Category Equals Certain Value And Another Category Another Value" request received
Hello, At the moment I have a category selection set up between two options, and depending on the option that get's selected it will add a specific value, as per the following: var cat = @Type Of Request cat == "International" ? 75.00 : cat == "National/Local" ? 25.00 : "" This is working perfectly, but I now have another category (seperate from above, so 2 different category options on the template), which I would like to also include in the calculation in the following way. If the first category like above is one of 2 options, as per above, it needs to add the value, BUT THEN it also needs to look at another category list and only if certain ones out of the list is selected, it needs to actually count the values for the first category selection? Example: 1st Category: 1st Option - International; 2nd Option - National IF International is selected, value should be 75.00; IF National is selected, value should be 25.00 2nd Category: 1st Option - Good, 2nd Option - OK, 3rd Option - Bad, 4th Option - Duplicate IF either of GOOD or OK gets selected it NEEDS TO count above values (from national & international); BUT IF BAD or DUPLICATE gets selected it shouldn't count the values

  • It works perfectly thanks Rainer....it seems like there was a 'space' added behind Good on the category selection....won't say anything further.... Thanks again!!
  • Hi Gert, everything looks ok. I've duplicated your setup and it works. See screenshots: http://goo.gl/c7C0fS http://goo.gl/9pVisY Please check the category options, if there is a blank space behind the option text (if so, delete the blank space). Is "Quality Of Lead" a single choice field? If it's multi choice the calculation has to changed ( I ask cause you have written in your last posting if 'Good' & 'Ok' is selected, but in your first posting: IF either of GOOD or OK gets selected Rainer
  • Hi Rainer, not sure how I can post a screenshot, but YES, it shows 0 even with the spelling the same. So just to be clear, I would like it to only count the values from 'Type Of Request' if 'Good' & 'Ok' is selected, if 'Bad', 'Pending' or 'Duplicate' is selected it shouldn't count the values. Herewith manual screenshot: 'Type Of Request' (Category 1) : 'Not Yet Allocated' (Option 1) [Value if selected 0.00] 'International' (Option 2) [Value if selected 75.00] 'National/Local' (Option 3) [Value if selected 25.00] 'Quality Of Lead' (Category 2) : 'Good' (Option 1) [Count above values if selected] 'Ok' (Option 2) [Count above values if selected] 'Bad' (Option 3) [DO NOT count above values if selected] 'Pending' (Option 4) [DO NOT count above values if selected] 'Duplicate' (Option 5) [DO NOT count above values if selected] 'Cost Of Lead' (Calculation Field): var cat1 = @Type Of Request var cat1calc = cat1 == "International" ? 75.00 : cat1 == "National/Local" ? 25.00 : ""; var cat2 = @Quality Of Lead; var cat2calc = cat2 == "Good" || cat2 == "Ok" ? "YES" : "NO" cat2calc == "YES" ? cat1calc : ""
  • Hi Gert, does it show 0 if you in cat1 one of the 2 options is selected and in cat2 "Good" or "Ok"? If so, did you enter "Good" and ""Ok" exactly the same way as inthe categor options? If they are exactly the same, please copy what you've entered into the calculation field or even better: Share a screenshot where the calculation field and the 2 category fields are shown.
  • Hey guys, not one of below works. Rainer, yours returns a 0 on both calculations, Hamid, yours throws out the following error: Script syntax error
  • Hi Gert, try like this var cat1 = @Type Of Request var cat2 = @Your_second_category var result_cat1 = cat1 == "International" ? 75.00 : cat1 == "National/Local" ? 25.00 : null var result_cat2 = cat2 == "GOOD" || "OK" ? result_cat1 : cat2 == "BAD" || "DUPLICATE" ? null : cat2 == null ? "cat2 not selected"
  • Hello Gert, you can use this: var cat1 = @Type Of Request var cat1calc = cat1 == "International" ? 75.00 : cat1 == "National/Local" ? 25.00 : ""; var cat2 = @2nd Category; var cat2calc = cat2 == "Good" || cat2 == "OK" ? "YES" : "NO" cat2calc == "YES" ? cat1calc : "" Or: var cat = @Type Of Request; var cat2 = @2nd Category; var cat2calc = cat2 == "Good" || cat2 == "OK" ? "YES" : "NO" cat == "International" && cat2calc == "YES" ? 75.00 : cat == "National/Local" && cat2calc == "YES" ? 25.00 : "" Rainer
This question is closed.