How to control decimal places in custom formula field

Started by Jennifer, May 15, 2015, 06:26:40 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Jennifer

If I place a rectangle shape, insert a field, select the Geometry category, select Width or Height, click on Data Format, and set the number of decimal places, the number that is displayed is rounded appropriately.

The same is true if I select the Custom Formula Category and enter "=Width" in the Custom Formula field.

But if I enter a formula like "=Width&" x "&Height", the number of decimal places setting is ignored.

Is there a way to get that to work right?
Using Visio 2019, part of Office 365 on Windows 10

JohnGoldsmith

Hello Jennifer,

You don't need to split up your formula into strings - you just write it as you would in the ShapeSheet. 

Here's an example in the attached image.

Best regards

John
John Goldsmith - Visio MVP
http://visualsignals.typepad.co.uk/

Jennifer

John,

I am not trying to show the area. I am trying to show both the width and the height.

Suppose I have a rectangle with width=3.01234 and height=2.56789. I wold like to generate a display showing the width and height to 1 or 2 decimal places, like this:

     W=3.01, H=2.57
     W=3.0, H=2.6

If I use this formula,

     ="W="&Width&", H="&Height

with the General data format category, I get this:

     W=3.01234", H=2.56789"

Switching to the Number category and setting the number of decimal places has no effect. I get the same display.

Is there a way to get the display with the valued rounded to a specified number of decimal places?
Using Visio 2019, part of Office 365 on Windows 10

JohnGoldsmith

Hi,

That's because the whole formula is seen as a string.  So instead you need to format each dimension value like this:

="W="&FORMAT(Width,"0.00")&", H="&FORMAT(Height,"0.00")

Have a look at format pictures for more options on the displayed result.

Best regards

John
John Goldsmith - Visio MVP
http://visualsignals.typepad.co.uk/

Jennifer

Using Visio 2019, part of Office 365 on Windows 10