UK Users Group

Expand all | Collapse all

Stop zero values from being displayed as a label

  • 1.  Stop zero values from being displayed as a label

    Posted 06-07-2018 17:04

    Another follow-up to yesterdays event. @Warren Vick? can you share the top tip for omitting zero values from being displayed when labelling objects?



  • 2.  RE: Stop zero values from being displayed as a label

    Posted 06-07-2018 13:19

    Hi John. Yes, happy to.

    I demonstrated Ordnance Survey AddressBase Plus with almost 39 million address records in a 80GB+ TAB Extended file set. One of the fields is the house number (integer), which is quite nice to use for labeling over building polygons or satellite/aerial imagery. A problem occurs, however, when a building as a name rather than a number. Since TAB(X) doesn’t have the concept of NULL, the value zero is used in this data set. Simple labeling causes wanted zeros to appear on the map. There’s a quick trick to display house numbers, except zeros using the format$() function. This MapBasic function is quite useful as it can present numbers in a number of formats. The function can be used if you label with an “Expression” with:

    format$(house_number, ".")

    I also have a more advanced expression which shows the building name, if there is one, alternatively the number where non-zero (as above). Interested in this one too? Equipped with MapBasic functions, in particular left$(), you can do all sorts of conditional labeling in Pro. Perhaps a good topic for a presentation sometime.

    BR/

    Warren



  • 3.  RE: Stop zero values from being displayed as a label

    Posted 06-07-2018 14:00
    And to add to this, the new IIf() function in MapInfo Pro 17 makes building conditional labelling much easier.


  • 4.  RE: Stop zero values from being displayed as a label

    Posted 06-07-2018 14:52

    That's a very handy new function, especially for labeling, although I might get confused with the mathematical iff!

    I presume the expression for the problem above would be something like:

    iif(house_number, house_number, "")

    or to conditionally bring in the building name:

    iif(building_name<>"",building_name, iif(house_number, house_number, ""))

    This is all much easier than string/expression wrangling with left$(), len(), etc.



  • 5.  RE: Stop zero values from being displayed as a label

    Posted 06-07-2018 17:03

    For multiple conditions you can also use the new Cond() function.

    Where the IIf() is similar to the If statement, the Cond() is similar to the Do Case statement.

    Your example could look like:

    Cond(1, building_name<>"", building_name, house_number, house_number, "")

    The last "" is the default value returned if none of the other conditions are met.



  • 6.  RE: Stop zero values from being displayed as a label

    Posted 07-09-2018 10:59

    @Warren Vick?  - so what was the more advanced expression that you had used?

    And were you using it to update a new column with an address string?



  • 7.  RE: Stop zero values from being displayed as a label

    Posted 08-21-2018 03:22

    Check this article for the "advanced expression" that you needed to use before we added the IIf() and Cond() functions:

    https://li360.pitneybowes.com/s/article/How-Create-a-Conditional-Labelling-MapInfo-Professional



  • 8.  RE: Stop zero values from being displayed as a label

    Posted 05-22-2019 06:30
    Peter,

    thanks for that link, and I realise it's a while ago, but it's now disappeared.  I am still using MapInfo Pro 15.0, so would be interested in older solutions to non-display of zero values.  Is the information that was in that link available somewhere else?

    Thanks.

    Alan.

    ------------------------------
    A O
    Knowledge Community Shared Account
    Shelton CT
    ------------------------------



  • 9.  RE: Stop zero values from being displayed as a label

    Posted 05-23-2019 03:29
    Hi Alan,

    Warren gave this example of an expression that would not show zeros in a label:
    format$(house_number, ".")

    Let us know if this was what you were looking for

    ------------------------------
    Peter Horsbøll Møller
    Pitney Bowes
    ------------------------------