Post

2 followers Follow
0
Avatar

simple if else statement

Hi,
I'm looking to make a simple if else statement but I don't know the basics. Below is what I'm trying to do...

If the field @City = "Baltimore"
Then the result should be @Tax assessment * 0.0236

If the field @City = "Dundalk"
Then the result should be @Tax assessment * 0.011

if it's anything else (e.g., other than dundalk or baltimore), then the result should be @Tax assessment * 0.01

Thanks!
-Will

Will Laughton

Please sign in to leave a comment.

1 comment

0
Avatar

Hi Will,

var city = @City;
var tax = @Tax assessment;
var number = city == "Baltimore" ? 0,0236 : city == "Dundalk" ? 0.011 : 0.01;
tax * number

That calculation works for single choice category fields or text fields where the name of only one city is in. 
For multi choice category fields it's: 

var number = city.indexOf( "Baltimore") > -1 ? 0,0236 : city.indexOf("Dundalk") > -1 ? 0.011 : 0.01;

Rainer

Rainer Grabowski 0 votes