Firstly this is similar to If-Then Label Expression BUT I need this for Mapinfo.

So I want to do the following in Mapinfo in the label expression box in ver 12.

if RuralAdd='R':
 address=St_No + " ; " + LotPlan

Is this possible? without creating a new column with this info using SQL.

===== @T_Bacon suggested I get the following but the lots with 0 St_No_1 still get a O in it. My code is

St_No_1+Left$(Chr$(13)+LOTPLAN, Len(LOTPLAN)*Int(Suf_No_1="R")*Int(St_No_1<>0))

output is enter image description here

1 Answer 1


Yes, you can do this but it's not as easy as a simple If-Then unfortunately! The workaround here is to use the Int() function to generate a 1 or a 0 from a conditional statement and then use this as a multiplier for the length value of a string function. So, in your example case you could do this:

Left$(St_No_1, Len(St_No_1) * Int(St_No_1 <> 0)) + 
Left$(" ; " + LOTPLAN, Len(" ; " + LOTPLAN) * Int(RuralAdd = "R") * Int(St_No_1 <> 0))
  • Brilliant. One other complication that I found when I ran this. It should not put any label where the St_No is '0' or Null.. Can we add this condition. Would it be something like ...{ "R") * Int (St_No <> 0))... }?
    – GeorgeC
    Feb 24, 2016 at 14:56
  • Yes, that should do it if it's a numerical field. If it's a character column then you will need to change it to test for both "0" and "".
    – T_Bacon
    Feb 24, 2016 at 15:02
  • I tried the following but it still prints the 0. It doesn't print in the lots with null though. {St_No_1+Left$(" ; "+LOTPLAN, Len(" ; "+LOTPLAN)*Int(Suf_No_1="R") * Int (St_No_1<>0))}
    – GeorgeC
    Feb 24, 2016 at 15:06
  • Is the field St_No_1 a character field? If so you will need to put double quotations around the 0, eg. Int(St_No_1<> "0")
    – T_Bacon
    Feb 24, 2016 at 15:55
  • 1
    Ok, I think I understand the problem, I should have read through the original post again. Just to confirm that I'm right, you don't want ANY label on any records with an St_No_1 of 0? I've updated my answer to reflect that change, hopefully that's what you were after!
    – T_Bacon
    Feb 25, 2016 at 8:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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