"Translate" Expression not working in Feature Labels

"Translate" Expression not working in Feature Labels

meldarzi
Participant Participant
776 Views
5 Replies
Message 1 of 6

"Translate" Expression not working in Feature Labels

meldarzi
Participant
Participant

The shapefile that I am connected to has object data "SYSTEMTYPE" = Abandoned, Existing, ProposedReplace, etc. I am trying to use the translate feature to return an alternate text, but the results are rather bizarre. The text return often contains symbols and is not part of the intended set. Is there a workaround or another way to do this?

0 Likes
Accepted solutions (1)
777 Views
5 Replies
Replies (5)
Message 2 of 6

ChicagoLooper
Mentor
Mentor

Hi @meldarzi 

 

 

1. VERIFY AND MAKE SURE YOU'RE TRANSLATING THE CORRECT ATTRIBUTE

We must first confirm the column heading is actually named SYSTEMTYPE and the values in that column are Abandoned, Existing, ProposedReplace, etc.

 

Open the 'Table View' of the shapefile you're connected to.

Upload a screenshot of the SYSTEMTYPE column from the Table View.

 

2. DIAGNOSE THE VALIDITY OF YOUR TRANSLATE EXPRESSION

Upload a screenshot of the  Modify Query window where you are building (writing) your query.

 

Before you take that screenshot, hit the Validate button next to check symbol in the lower left corner of the Modify Query window so error messages will be captured in the screenshot.

Chicagolooper

EESignature

Message 3 of 6

O_Eckmann
Mentor
Mentor
Accepted solution

Hi @meldarzi ,

 

If I've well understood the usage of translate :

image.png

With Translate (FIELDNAME, 'A', '_'), it replaces all letters A found in the field value by a _

With Translate (FIELDNAME, 'AB', '_+'), it replaces all letters A (1st character of 1st parameter) found in the field value by a _ (1st character of 2nd parameter) AND all letters B (2nd character of 1st parameter) by a + (2nd character of 2nd parameter)

With Translate (FIELDNAME, 'ABC', '_+'), it replaces all letters A (1st character of 1st parameter) found in the field value by a _ (1st character of 2nd parameter) AND all letters B (2nd character of 1st parameter) by a + (2nd character of 2nd parameter) AND letter C (3rd character of 1st parameter) by nothing (only 2 characters in 2nd parameter) So after the first 2 replacements, if other part of text string contains a letter C, all other characters are removed, and if it doesn't contain letter C, no other replacement are done.

 

In your case if you want to keep only 2 first letters, it's better to use 

 Upper ( Substr ( SYSTEMTYPE , 1, 2 ) )

to obtain AB for Abandoned, EX for Existing and PR for ProposeReplace

Olivier Eckmann

EESignature

Message 4 of 6

meldarzi
Participant
Participant

Thanks @ChicagoLooper, I've checked the following and everything looks to be good. The issue appears to be my use of the translate expression

0 Likes
Message 5 of 6

meldarzi
Participant
Participant

Thanks @O_Eckmann, I suspected my use of the translate expression was at fault. I was assuming it would run as a simple "find and replace". Kind of confused why the expression is structured like this though.

0 Likes
Message 6 of 6

ChicagoLooper
Mentor
Mentor

Screenshots showing your expression? Can you share two screenshots?

 

1. An image of your expression.

ChicagoLooper_0-1723236419393.png

 

2. An image of the database file (dbf) showing the Table view.

 ChicagoLooper_1-1723236532757.png

 

 

Chicagolooper

EESignature

0 Likes