Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

We are troubleshooting an issue impacting community login, and it may be intermittently unavailable. Sorry for any inconvenience.

- Community
- Systems/Software Engineering
- Systems/Software Engineering
- Re: Computed Expression help

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

May 16, 2014
10:40 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

May 16, 2014
10:40 AM

Computed Expression help

We are using MKS Integrity 2009 SP5. Yes, I know we need to upgrade, but we are under-staffed.

I am trying to make a calculation (Computed expression Integer type field) work. When I try to edit an item I get an error "Division by zero has been detected processing the query on the server". I understand the error. I don't know how I can resolve it. What I am doing is dividing 2 integer fields to return a percentage. Example: field3 (Integer) computed expression: **"field1" / "field2"**. These 2 fields are divided to give a percentage.

If field1 = 10 and field2 = 100 then field3 should display 10%.

However, if field1 and/or field2 has zero (default) then the division error is displayed. I understand you cannot divide a number by zero.

If field1 = 0 and field2 = 100 then field3 should display 0%.

How can I get it to simply calculate or say 0%, because that is what it should be?

Thank you,

Solved! Go to Solution.

ACCEPTED SOLUTION

Accepted Solutions

May 16, 2014
11:09 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

May 16, 2014
11:09 AM

Hi Daniel,

1. IMHO the field type of your computed "Field3" should be "floating point".

2. IMHO the computaion should be:

isEmpty( ("field1") / ("field2" + 0.001),0.)

HTH Matthias

4 REPLIES 4

May 16, 2014
11:09 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

May 16, 2014
11:09 AM

Hi Daniel,

1. IMHO the field type of your computed "Field3" should be "floating point".

2. IMHO the computaion should be:

isEmpty( ("field1") / ("field2" + 0.001),0.)

HTH Matthias

May 16, 2014
11:39 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

May 16, 2014
11:39 AM

Is it safe to assume that I cannot mix apples and oranges. So all those fields should be floating point. Correct?

May 19, 2014
08:07 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

May 19, 2014
08:07 AM

As far as I know, the resulting field Type is the driver.

So, as long as you are calculyting a floating point field, the calculation may still contain integer values.

At least in the field definitions of the PTC ALM Solution this is used several times.

May 19, 2014
09:21 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

May 19, 2014
09:21 AM

All correct. The only one that _has_ to be float is the final computation. Others can be or not. Where integers are divided and nested, I've also had to multiply the ratio by 1.0 to prevent the result from being rounded to integer before the next operator is applied. THAT trick is the least obvious. When in doubt, try it.