Computed field expression: AND or OR

Hi all,

Just had a strange problem.

In a computed field expression I placed following statement:
(Value of prc_discount = 0 )

- IF( NOT IsNull( prc_discount ) AND prc_discount <> 0, 'Show text',
'' ) --> Result = 'Show text'

Now by changing the expression to:

- IF( IsNull( prc_discount ) OR prc_discount = 0, '', 'Show text' ) -->
Result = ''

Can someone explain this behaviour, because I'm totally lost.

(PB 8.0.1 Build 9056  on a W2K workstation)

TIA,
PascalB


0
PascalB
7/18/2005 12:15:27 PM
sybase.powerbuilder.datawindow 28057 articles. 4 followers. Follow

6 Replies
581 Views

Similar Articles

[PageSpeed] 37

Hi Pascal,

just a shot in the dark:
Use braces around every part of logical connected expressions:

IF( (NOT IsNull( prc_discount )) AND (prc_discount <> 0), 'Show text','' )

- IF( (IsNull( prc_discount )) OR (prc_discount = 0), '', 'Show text' )

HTH

    Chris Werner

"PascalB (Search4)" <mail@mail.mail> schrieb im Newsbeitrag 
news:42db9d5a$1@forums-2-dub...
> Hi all,
>
> Just had a strange problem.
>
> In a computed field expression I placed following statement:
> (Value of prc_discount = 0 )
>
> - IF( NOT IsNull( prc_discount ) AND prc_discount <> 0, 'Show text',
> '' ) --> Result = 'Show text'
>
> Now by changing the expression to:
>
> - IF( IsNull( prc_discount ) OR prc_discount = 0, '', 'Show text' ) -->
> Result = ''
>
> Can someone explain this behaviour, because I'm totally lost.
>
> (PB 8.0.1 Build 9056  on a W2K workstation)
>
> TIA,
> PascalB
>
> 


0
Chris
7/18/2005 12:34:27 PM
Hi Chris,

Thanks for the reply.
That's not just a shot in the dark... it works!!

The logic of both expressions should return the same result right?
So why didn't the expression using AND give the correct result (without the
use of braces) ?
(That's the part I didn't understand so far)

TIA,
PascalB



"Chris Werner" <cw{please_no_spam}ATf-s.de> wrote in message
news:42dba1d0$1@forums-2-dub...
> Hi Pascal,
>
> just a shot in the dark:
> Use braces around every part of logical connected expressions:
>
> IF( (NOT IsNull( prc_discount )) AND (prc_discount <> 0), 'Show text','' )
>
> - IF( (IsNull( prc_discount )) OR (prc_discount = 0), '', 'Show text' )
>
> HTH
>
>     Chris Werner
>
> "PascalB (Search4)" <mail@mail.mail> schrieb im Newsbeitrag
> news:42db9d5a$1@forums-2-dub...
> > Hi all,
> >
> > Just had a strange problem.
> >
> > In a computed field expression I placed following statement:
> > (Value of prc_discount = 0 )
> >
> > - IF( NOT IsNull( prc_discount ) AND prc_discount <> 0, 'Show text',
> > '' ) --> Result = 'Show text'
> >
> > Now by changing the expression to:
> >
> > - IF( IsNull( prc_discount ) OR prc_discount = 0, '', 'Show text' ) -->
> > Result = ''
> >
> > Can someone explain this behaviour, because I'm totally lost.
> >
> > (PB 8.0.1 Build 9056  on a W2K workstation)
> >
> > TIA,
> > PascalB
> >
> >
>
>


0
PascalB
7/18/2005 12:57:15 PM
Could be a bug in operator precedence.  PB may be attempting to
process the AND before the <> (though <> should come first)..

On 18 Jul 2005 05:57:15 -0700, "PascalB \(Search4\)" <mail@mail.mail>
wrote:

>Hi Chris,
>
>Thanks for the reply.
>That's not just a shot in the dark... it works!!
>
>The logic of both expressions should return the same result right?
>So why didn't the expression using AND give the correct result (without the
>use of braces) ?
>(That's the part I didn't understand so far)
>
>TIA,
>PascalB
>
>
>
>"Chris Werner" <cw{please_no_spam}ATf-s.de> wrote in message
>news:42dba1d0$1@forums-2-dub...
>> Hi Pascal,
>>
>> just a shot in the dark:
>> Use braces around every part of logical connected expressions:
>>
>> IF( (NOT IsNull( prc_discount )) AND (prc_discount <> 0), 'Show text','' )
>>
>> - IF( (IsNull( prc_discount )) OR (prc_discount = 0), '', 'Show text' )
>>
>> HTH
>>
>>     Chris Werner
>>
>> "PascalB (Search4)" <mail@mail.mail> schrieb im Newsbeitrag
>> news:42db9d5a$1@forums-2-dub...
>> > Hi all,
>> >
>> > Just had a strange problem.
>> >
>> > In a computed field expression I placed following statement:
>> > (Value of prc_discount = 0 )
>> >
>> > - IF( NOT IsNull( prc_discount ) AND prc_discount <> 0, 'Show text',
>> > '' ) --> Result = 'Show text'
>> >
>> > Now by changing the expression to:
>> >
>> > - IF( IsNull( prc_discount ) OR prc_discount = 0, '', 'Show text' ) -->
>> > Result = ''
>> >
>> > Can someone explain this behaviour, because I'm totally lost.
>> >
>> > (PB 8.0.1 Build 9056  on a W2K workstation)
>> >
>> > TIA,
>> > PascalB
>> >
>> >
>>
>>
>

Bruce Armstrong [TeamSybase]
http://www.teamsybase.com

In Defense of Top Posting
http://alpage.ath.cx/toppost/toppost.htm

Preach the gospel at all times. If necessary, use words. - Francis of Assisi
http://www.needhim.org
0
Bruce
7/18/2005 1:27:59 PM
I'll (try to) keep it in mind...   :o)
Thanks Bruce.

Greets,
PascalB



"Bruce Armstrong [TeamSybase]" <NOCANSPAM_bruce.armstrong@teamsybase.com>
wrote in message news:hcbnd1h3o1e5eua2352qishc4nje05cstg@4ax.com...
> Could be a bug in operator precedence.  PB may be attempting to
> process the AND before the <> (though <> should come first)..
>
> On 18 Jul 2005 05:57:15 -0700, "PascalB \(Search4\)" <mail@mail.mail>
> wrote:
>
> >Hi Chris,
> >
> >Thanks for the reply.
> >That's not just a shot in the dark... it works!!
> >
> >The logic of both expressions should return the same result right?
> >So why didn't the expression using AND give the correct result (without
the
> >use of braces) ?
> >(That's the part I didn't understand so far)
> >
> >TIA,
> >PascalB
> >
> >
> >
> >"Chris Werner" <cw{please_no_spam}ATf-s.de> wrote in message
> >news:42dba1d0$1@forums-2-dub...
> >> Hi Pascal,
> >>
> >> just a shot in the dark:
> >> Use braces around every part of logical connected expressions:
> >>
> >> IF( (NOT IsNull( prc_discount )) AND (prc_discount <> 0), 'Show
text','' )
> >>
> >> - IF( (IsNull( prc_discount )) OR (prc_discount = 0), '', 'Show text' )
> >>
> >> HTH
> >>
> >>     Chris Werner
> >>
> >> "PascalB (Search4)" <mail@mail.mail> schrieb im Newsbeitrag
> >> news:42db9d5a$1@forums-2-dub...
> >> > Hi all,
> >> >
> >> > Just had a strange problem.
> >> >
> >> > In a computed field expression I placed following statement:
> >> > (Value of prc_discount = 0 )
> >> >
> >> > - IF( NOT IsNull( prc_discount ) AND prc_discount <> 0, 'Show text',
> >> > '' ) --> Result = 'Show text'
> >> >
> >> > Now by changing the expression to:
> >> >
> >> > - IF( IsNull( prc_discount ) OR prc_discount = 0, '', 'Show
text' ) -->
> >> > Result = ''
> >> >
> >> > Can someone explain this behaviour, because I'm totally lost.
> >> >
> >> > (PB 8.0.1 Build 9056  on a W2K workstation)
> >> >
> >> > TIA,
> >> > PascalB
> >> >
> >> >
> >>
> >>
> >
>
> Bruce Armstrong [TeamSybase]
> http://www.teamsybase.com
>
> In Defense of Top Posting
> http://alpage.ath.cx/toppost/toppost.htm
>
> Preach the gospel at all times. If necessary, use words. - Francis of
Assisi
> http://www.needhim.org


0
PascalB
7/18/2005 2:04:55 PM
The NOT is performed LAST

Equivalent expression:
          4                     1                     3                   2
IF( NOT ((IsNull( prc_discount )) AND (prc_discount <> 0)), 'Show text','')

datawindow operator precedence:
( ) - Grouping
^   - Exponentiation
*, / - Multiplication and division
+, - - Addition and subtraction; string concatenation
=, >, <, <=, >=, <> : Relational operators
AND,OR : Logical and and logical or
NOT : Logical negation


"PascalB (Search4)" <mail@mail.mail> wrote in message
news:42db9d5a$1@forums-2-dub...
> Hi all,
>
> Just had a strange problem.
>
> In a computed field expression I placed following statement:
> (Value of prc_discount = 0 )
>
> - IF( NOT IsNull( prc_discount ) AND prc_discount <> 0, 'Show text',
> '' ) --> Result = 'Show text'
>
> Now by changing the expression to:
>
> - IF( IsNull( prc_discount ) OR prc_discount = 0, '', 'Show text' ) -->
> Result = ''
>
> Can someone explain this behaviour, because I'm totally lost.
>
> (PB 8.0.1 Build 9056  on a W2K workstation)
>
> TIA,
> PascalB
>
>


0
MItch
7/18/2005 5:27:17 PM
Thanks Mitch.

Didn't see this one coming :o(

You're right about this, just found it in the help-file: 'Operator
precedence in Datawindow expressions'

I thought it would seperatly evaluate the conditions and then did the 'AND'
evaluation last.
More like:
1.  NOT IsNull( prc_discount )
2.  prc_discount <> 0
3.  AND

I was wrong....never the less, it has been a good lesson for me.

Greets,
PascalB


"MItch Wade" <mwade@uectech.com> wrote in message
news:42dbe671$2@forums-2-dub...
> The NOT is performed LAST
>
> Equivalent expression:
>           4                     1                     3
2
> IF( NOT ((IsNull( prc_discount )) AND (prc_discount <> 0)), 'Show
text','')
>
> datawindow operator precedence:
> ( ) - Grouping
> ^   - Exponentiation
> *, / - Multiplication and division
> +, - - Addition and subtraction; string concatenation
> =, >, <, <=, >=, <> : Relational operators
> AND,OR : Logical and and logical or
> NOT : Logical negation
>
>
> "PascalB (Search4)" <mail@mail.mail> wrote in message
> news:42db9d5a$1@forums-2-dub...
> > Hi all,
> >
> > Just had a strange problem.
> >
> > In a computed field expression I placed following statement:
> > (Value of prc_discount = 0 )
> >
> > - IF( NOT IsNull( prc_discount ) AND prc_discount <> 0, 'Show text',
> > '' ) --> Result = 'Show text'
> >
> > Now by changing the expression to:
> >
> > - IF( IsNull( prc_discount ) OR prc_discount = 0, '', 'Show text' ) -->
> > Result = ''
> >
> > Can someone explain this behaviour, because I'm totally lost.
> >
> > (PB 8.0.1 Build 9056  on a W2K workstation)
> >
> > TIA,
> > PascalB
> >
> >
>
>


0
PascalB
7/19/2005 7:45:08 AM
Reply:

Similar Artilces:

computed field of a computed field
Hello, I made nice datawindow with some aggregate functions to calculate a certain value at a group level. Now I want a grand total which gives me the sum of these values. Unfortunately this does not seem to be possible. So, when I have a computed field which is round (sum(file_field),0) located in the trailer band, I need a grand total of this field in the summary band. Does anyone know how to solve this ? Philip. Philip@acom.be (Belgium) Philip, in the group , you must have created a computed field having expression sum ( file_field ) for group 1 In the summery, y...

Datawindows and Computed Fields
I am using PB 8 and have several formatted datawindows providing reports for the end user. What has been requested of me and I am having trouble with is as follows. I have a datawindow with a nested datawindow. The main datawindow object contains the "parent" record and the nested one contains "child" records. Basically an Agency has subagencies. This report is to be used to create a manual. Where I am having the problem is that the page numbering is done using a computed field placed in the header (or footer or detail for that matter). I need to know the page...

Computed field expressions
Hi all, I have a problem with computed expressions. I am replacing occurence of a particular string in a computed field with another string( say from 'mm/dd/yy ' to 'dd/mm/yy') using powerscript and when I try to modify the expression it works in some cases and fails in other cases. For ex ls_syntax = ls_computename + ".Expression = " + "'"+ ls_expression + "'" this.modify(ls_syntax) In the above I get a Modify Syntax error in some cases. Therefore, I need a universal syntax that would work under all cases. Does a...

Computed field in a datawindow
How do I make a computed field in a datawindow editable? You can't. But you can create computed column. It has a tab order. Go to SQL painter of datawindow, go to computed, place 0 for number type of editable column, '' for string type of editable column -- Mahendra Dhamdhere, CPDA Email:nospam_mahendrad@hotmail.com Pl. Remove nospam_ from email id Shobana Juliana wrote: > How do I make a computed field in a datawindow editable? >How do I make a computed field in a datawindow editable? You don't. If you need for the user to be able to e...

computed field expression
I have this statement but it is not producing the desired results. I have 2 computed fields that are supposed to get the total amount for cash and the total for credit. compute_1: If( payment_payment_form <> 'cash', sum( payment_amount for all),0) compute_2: If ( payment_payment_form ='cash, sum( payment_amount for all),0) Obviously this aboue just produces the total for both cash and credit. I can't get the syntax right but I need something like; If ( payment_payment_form ='cash, sum( payment_amount for all) where payment_form = cash,0) Any ideas?...

Computed field in Datawindow
PB version: 6.5 A computed field in a datawindow have not a tab order. So, i can�t go to this field and do a 'Copy and Paste' of the value of this field. Thanks... try to use computed column, u can't use computed field for copy & paste as it does not have tab order, it is only for display. ...

Computing Computed Field
I Have a computed field in tailor band of a group. I tried to sum that computed field in summary band using another computed expression ..It is displaying 0 instead of sum I appreciated any help Thanks Sue IF you use the format sum(x for group 1) in Tailor group then use sum(x for all) in summary. Stephan Donati Fortisoft Corporation "Sue Sambireddy" <SSambireddy@bankofny.com> wrote in message news:3AE83A22.AF41D7BC@bankofny.com... > I Have a computed field in tailor band of a group. I tried to sum > that computed field in summary band using a...

Computing computed field
I Have a computed field in tailor band of a group. I tried to sum that computed field in summary band using another computed expression ..It is displaying 0 instead of sum . I appreciated any help Thanks Sue You can place the expression from the second field in the first one instead of referring to it. Another option (often works) is to apply the GroupCalc DataWindow method (of course outside the expression in the script where you issue Retrieve(), for example.). Sue Sambireddy wrote: > I Have a computed field in tailor band of a group. I tried to sum > t...

Computed Field not computing
I have a series of computed fields that calculate percentages and then a series that total those percentages. When I add the third total percentage field (out of four total) to my group trailer, all my total percentage fields sum to 0 when they should all sum to 100. If I move the third computed field into another band then they all sum to 100 and when I put it back they all still compute to 100. Why would this happen? I know computed fields constantly re-compute, but these are not initially computing correctly based on the number of computed fields present in my group trailer band...

summation of computed fields under datawindow
Just one quick & simple quesion. However, i do get stuck with this for a long time. How can i sum up the total of the computed fields? Example: ComField = sum (A for group 1) where A=column However, at the end of my report, i coded "sum(ComField for all)", i only got "0". Is there anyway syntax to sum the computed fields at the end of the report. Thanks in advance! Joe, You may have over-simplified your example, because you can just create a computed field with the expression "Sum (A for all)" and solve that particular problem. Is th...

Computed Field Expression #2
I have a computed field in the header band that I want to update with most current value of an instance variable. I am attempting to change the expression. It never displays. The modify statement returns an empty string showing me that the modify had no errors. What am I doing wrong and is there a better way to get an instance variable to display on a datawindow. Try a text object. It's simple. Just change the text. <DW Control Name>.Object.<Textname>.Text='<string>' -- Srinivas R. Loka "Rosalind Powell" <roz@brcf.org> wrote in m...

modify expressions in computed fields ?
Can i modify expressions in computed fields depends on the value in a column like other properties like color (exam: text.Color='0~t If (formel_id =1 ,255,0)' )?? thats my test_modstring: c_test.Expression='0~tIf(formel_id =1 ,1+1,0)' i have only Syntax error at the last column. Thank you very much! Sure you can. Off hand your syntax looks ok. Replace "forme1_id" with a constant and see if it accepts the syntax: '0~tIf(1=1 ,1+1,0)' First get it working in the DW painter. Then copy that syntax out and use it in your modify. Regards, John ...

Modifying Computed field Expression
Hello, We have a software package that we use in our business, where we have some control over customizations to the program. We don't have access to window objects, but we have access to certain datawindows and global functions. One global function runs when a window refreshes. The function contains a choose case statement to determine which window is opening. It then runs the script for that window. I have a computed field on a datawindow that just has an Expression of 0. I want to be able to have the Expression for the computed field get modified through this fun...

computed field conditional expression
Hi, I need to write a computed field to sum rows based on a condition, like a where clause. Like: sum( amount where level = 4) OR even better sum( amount where level = level), where 'level' and 'amount' are columns in the DW. Even though this computed field will be in the detail band, I want it to do some kind of grouping sum. I cant change the the expression for a row. TIA Sanjay Hi Geert, Thanks, I couldn't quite follow what you suggested. Could you elaborate. Let me elaborate. I want to sum a column lets say 'amount' and take only rows...

Web resources about - Computed field expression: AND or OR - sybase.powerbuilder.datawindow

Resources last updated: 11/28/2015 11:18:27 AM