0

I am pretty new to programming so I don't really understand how I can do this.

Basically I have data with field that are 0, I wanted to display "No Data" when the field is 0, and when it is not 0, for example 1977, I wanted to display "The building was built on 1977.

This is what I have right now

IIF($feature["YEAR_BUILT"]=="0", "No Data", $feature["YEAR_BUILT"])

However, when I want to add the string " The building was built on" like so,

IIF($feature["YEAR_BUILT"]=="0", "No Data", "The building was built on $feature["YEAR_BUILT"].")

The error message said unexpected token. How should i work around this?

2

I believe this line:

IIF($feature["YEAR_BUILT"]=="0", "No Data", "The building was built on $feature["YEAR_BUILT"].")

needs to be:

IIF($feature["YEAR_BUILT"]=="0", "No Data", "The building was built on " + $feature["YEAR_BUILT"] + ".")
  • Thank you so much for your reply. I tried the code you provide, but for 0 values, it returned as "The building was built on 0." However, other values works perfectly! – chmnata Jul 19 '18 at 22:38
  • Then your year_built field is actually a numeric field (not unreasonable for a year) so simply remove the quotes around the zero as currently you are testing if it is equal to a string that happens to hold a zero character. – Hornbydd Jul 19 '18 at 22:42

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.