Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formula Post Reply Post New Topic
Author Message
mjaffer
Newbie
Newbie


Joined: 01 Jun 2014
Location: United Kingdom
Online Status: Offline
Posts: 4
Quote mjaffer Replybullet Topic: Formula
     Posted: 03 Jun 2014 at 7:17am
I have a report in which I need to return 0 for the price field if a couple of conditions are true, otherwise return the price.

I have got this code in the formula:
if ({vwSalesOrdersPrint.FollowUp_Action} = "To Follow") OR ({vwSalesOrdersPrint.NoCharge} = TRUE) THEN
    0
ELSE
    {vwSalesOrdersPrint.Price};

It is only returning 0 and not the price. Can some tell me what is wrong with the formula.

Thanks
IP IP Logged
hello
Groupie
Groupie
Avatar

Joined: 05 Feb 2014
Online Status: Offline
Posts: 85
Quote hello Replybullet Posted: 03 Jun 2014 at 9:50am
Try:

NumberVar display_amt := 0;

If ({vwSalesOrdersPrint.FollowUp_Action} = "To Follow") OR ({vwSalesOrdersPrint.NoCharge} = TRUE)
Then
display_amt := 0
Else
display_amt := {vwSalesOrdersPrint.Price};

display_amt
IP IP Logged
mjaffer
Newbie
Newbie


Joined: 01 Jun 2014
Location: United Kingdom
Online Status: Offline
Posts: 4
Quote mjaffer Replybullet Posted: 03 Jun 2014 at 12:36pm
Hi thanks for the reply.
However this is only returning 0 where {vwSalesOrdersPrint.FollowUp_Action} = "To Follow". All the rest are blank.
IP IP Logged
kostya1122
Senior Member
Senior Member
Avatar

Joined: 13 Jun 2011
Online Status: Offline
Posts: 475
Quote kostya1122 Replybullet Posted: 04 Jun 2014 at 11:56am
the syntax looks fine
what exactly the formula spouse to accomplish ?

maybe change or to and

if ({vwSalesOrdersPrint.FollowUp_Action} = "To Follow")and({vwSalesOrdersPrint.NoCharge} = TRUE) THEN
    0
ELSE
    {vwSalesOrdersPrint.Price};



Edited by kostya1122 - 04 Jun 2014 at 1:58pm
IP IP Logged
mjaffer
Newbie
Newbie


Joined: 01 Jun 2014
Location: United Kingdom
Online Status: Offline
Posts: 4
Quote mjaffer Replybullet Posted: 04 Jun 2014 at 9:25pm
Hi kostya122
The records in the database can have one of the 3 conditions:
1. No charge items
2. FollowUp_Action = an action
3. everything else

IF either condition 1 or condition 2 is True, then 0 should be returned otherwise the price of the item should be returned.
IP IP Logged
BenWright
Newbie
Newbie


Joined: 04 Jun 2014
Location: United Kingdom
Online Status: Offline
Posts: 9
Quote BenWright Replybullet Posted: 05 Jun 2014 at 12:58am
Try enclosing the entire OR statement in brackets perhaps?

if (({vwSalesOrdersPrint.FollowUp_Action} = "To Follow") OR ({vwSalesOrdersPrint.NoCharge} = TRUE)) THEN
    0
ELSE
    {vwSalesOrdersPrint.Price};
IP IP Logged
mjaffer
Newbie
Newbie


Joined: 01 Jun 2014
Location: United Kingdom
Online Status: Offline
Posts: 4
Quote mjaffer Replybullet Posted: 05 Jun 2014 at 7:35am
Thanks for your help everyone. I resolved it by using this formula:
If {vwSalesOrdersPrint.NoCharge} = TRUE Then
    0
ELSE
    {vwSalesOrdersPrint.Price} ;

I then suppress the value if FollowUp_Action = "To Follow".

It does what I want it to do.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum