"related() not working

I have the following formula in a text display object, and the TD object has its property set to “Formula”:

related({AP 2015 Code}, “New AP Customer List”)

This seems to follow the form in the documentation

I get the following error string in the object:
“Expression contains an operand when an operator was expected”

This function is attempting to replace the following lookup function which works:

lookup(“New AP Customer List”, «Combined Name», «Combined Name», “AP 2016 Code”, “NA”)

I don’t have a clue as to what is wrong.

Try adding chevrons:

related({«AP 2015 Code»}, “New AP Customer List”)
1 Like

Thank you very much. That worked. I’m used to chevrons, but brackets are new to me. Where, when, why? Feel free to point me to a page.

Brackets are simply an alternate way of quoting text. They are often used when the text to be quoted might contain quotation marks.

After many years of using Panorama, I still consult the help page to get the syntax of statements and functions, where it will tell you if you need curly brackets.

The related( Help page does not give an example of how to handle a field name with spaces so it is understandable that Sam got confused with the way to set up the formula. Since the parameter is a formula that is going to be used “as is” in the function. It has to be written so that it make sense when it is executed. I’ll use a simple execute statement to show what is happening.

If I want the field named “Test Field” to be set to a value using execute with a variable having the field’s name and write it like this:

let x="Test Field"
execute x+{="Something"}

I’ll get an error because the field name has a space and will be executed as:

Test Field="Something"

Now if I write the code like this:

let x="«Test Field»"
execute x+{="Something"}

It executes as:

«Test Field»="Something"

I always try to eliminate spaces in my field names and this is very easy now that we have the option in the Field Properties Dialog to set the Title to something other than the actual field name. So, in my example above I could have the actual field name as “TestField” and have the title set to “Test Field” for display in the datasheet. Now both versions of the formula would work once I change the value of x to “TestField”. The down side is that you have to remember that the actual field name is other than what is displayed in the datasheet when coding a procedure.

Hope this casts a little light on the subject and doesn’t make it even more confusing.

It does clarify much. I had been thinking of chevrons as a way to quote field names, but really it is a way to identify the characters between the chevrons as a field name.
Thank you.

Thanks for this, Gary. I don’t often fall into this particular trap but I’m operating mostly by rote. This really clarified things for me.

There is some truth to both of these ideas. Chevrons play the same role with field (or variable) names that quotes do with strings of text. They indicate where the name begins and ends, and that every character between them is simply part of the name, and doesn’t serve any special function. Commas, spaces, asterisks, hyphens, parentheses, plus signs, slashes, etc. could all be included in the name, as long as you put chevrons around that name.

They also serve to indicate that this is a field or variable, and not a text constant.

This topic is covered in a help page, but I think Gary’s explanation above is better!