## Resolved Computed fields in groups

0
Undo
1. Raymond Longoria
2. PowerBuilder
3. Wednesday, 7 June 2023 23:44 PM UTC

I have a datawindow with 2 groups. In trailer group 2, I have a computed field that does a SUM on a column (computed field #1) and another one (computed field #2) that has an IF statement that if true will result in the value of computed field #1. This is working fine.

In trailer group 1, I add a computed field that does a SUM of computed field #2 and when i verify if it I get the following message:

Expecting NUMBER Expression

Any help would be appreciated.

John Fauss Accepted Answer Pending Moderation
1. Thursday, 8 June 2023 17:54 PM UTC
2. PowerBuilder

Thanks for the information. As a test, try replacing the expression in computed field #2 with zero (0). If that eliminates the error, restore the original expression and enclose it in an additional If condition: If( IsNull( original-expression ), 0, original-expression). If replacing the expression with zero does NOT eliminate the problem, then the problem is likely somewhere else.

Comment
Responses (5)
Raymond Longoria Accepted Answer Pending Moderation
1. Thursday, 8 June 2023 23:35 PM UTC
2. PowerBuilder
3. # 1

John,

You suggestion worked and eliminated the error! Thank you for your help!

Comment
1. John Fauss
2. Friday, 9 June 2023 01:13 AM UTC
That's great news, Raymond! Thank you for letting me know.
Dan Cooperstock Accepted Answer Pending Moderation
1. Thursday, 8 June 2023 18:17 PM UTC
2. PowerBuilder
3. # 2

Why not just do the same calculation, but for everything in group 1, as you did in the computed field for group 2, rather than trying to have a sum of the computed field from the group 2 values?

So for instance if the computed field in group 2 was "sum(amount for group 2)" the computed field in group 1 will be "sum(amount for group 1)".

I'm not at all sure that compute expressions in a lower-numbered group can refer to names of computed fields in higher-numbered groups. (I certainly can't recall having ever either tried or needed to do that.)

Comment
Raymond Longoria Accepted Answer Pending Moderation
1. Thursday, 8 June 2023 16:09 PM UTC
2. PowerBuilder
3. # 3

computed field #2 - if(  bid_ranking =1,   c_bid_amount_total  , 0 )

c_bid_amount_total is computed field #1

This is what is in the DW source. I did not see what you stated:

expression="if(  bid_ranking =1,   c_bid_amount_total  , 0 )"

Comment
John Fauss Accepted Answer Pending Moderation
1. Thursday, 8 June 2023 02:09 AM UTC
2. PowerBuilder
3. # 4

Hi, Raymond -

What is the value of computed field #2 when the If condition being tested is false? Can you supply the expression for computed field #2?

If you edit the DW source and look at the line that defines computed field #2, what is the value of the "expression" property (it's near the start of the line). The reason I'm asking for this is I'd like to see the default value for the computed field (it precedes the tab character that separates the default value and actual expression you see in the expression builder dialog window).

I suspect this default value, if present, is NOT a number.

Best regards, John

Comment