Jump to content

Formulas in Data Tags

Recommended Posts

The short version of what I'm trying to accomplish is to show the absolute value of a coordinate in a data tag (for instance, if the coordinate is -20'0" on the X axis, I just want it to say 20'0"). I'm essentially dimensioning from a 0,0 point and the direction (which would be expressed as positive/negative) is irrelevant.


I do this in worksheets with a simple if/else formula: =IF((XCOORDINATE>0), XCOORDINATE, -(XCOORDINATE)) because I haven't run across an easier way. Some spreadsheets have an ABS(value) function, but I don't see this in VW.


My questions are:

- is it possible to put a a formula such as this in a data tag? I haven't had any luck, it just displays as text, but maybe I don't have the right syntax.

- either way, is there an easier way to get the figure I'm looking for?






Link to comment

XCOORDINATE does not exist in Data Tags, but the object insertion point of the Data Tag does using a tag of #IPX#.


IF/Then is weird in Data Tags. It uses a formula of

<Value_If_True>@<The_Condition>:<Value_If_False>. Don't use any spaces between things.


So I think the following will give you what you want:




Thank you to @michaelk for helping me refine this syntax.


Ask again if you need more help.

  • Like 3
Link to comment

I'm sure your right, but that sort of syntax is supposed to entice users who are avoiding using vectorscript, python, or marionette?  It seems like they have given users access to a tool that they will use to fashion user requested labeling functionality.  I am consistently impressed by users who dig in to create their own custom solutions, so perhaps there will be a plethora of user data tag solutions.  It's easier for me to deal with vs.  I wonder why they didn't try to stay consistent with worksheet syntax.

  • Like 2
Link to comment

My guess is that this is the syntax used by whatever parser they are using under the hood and they didn't have time to wrap it in something better. This is actually very close to a standard Python if then construct which could be like:


<Value if True>?<The Condition>:<Value if False>


They probably changed to @ because the question mark was being used for something else.


I believe/hope that it will be better in future versions, but at least it works in VW2021.


And I completely agree with you that it is almost unusable for anyone not familiar with programming. Or having a friend on the forum who likes digging into obscure questions. 😉

  • Like 3
Link to comment

Out of curiosity only.

If the condition cannot be evaluated does the parser capture for processing either the true or false value?; or throw an error dialog or a null value?


The way it is written reminds me of a process without error checking. If read left to right it would capture the false value into the register then process the condition where by a true result would overwrite the register value with the next value to the left. (APL processed code lines left to right)

Where as Pascal or Basic+ type of formatting will have the condition for evaluation first resulting in selectively choosing to ignore either the first value or the second value and do a single write to the register. Hmmm. Overly simplified of course. hehe

Link to comment

It changed in 2019 or 2020.  @ used to be not a reserved character.  I'm looking through the help documents and I can't find it anymore, but there used to be 2 syntaxes for IF/THEN/ELSE statements in data tags.  The only one that I ever got to work (and even that only recently) is result@logic_statement:else


Like Pat said: No spaces to make it more readable 🙂.  I'm not positive about double quotation marks or single quotation marks.  I know I successfully use




The single quotes next to each other recognize a blank field, but all the examples of returning specific text uses double quotes.

  • Like 1
Link to comment
  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...