Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: a formula calculation problem Post Reply Post New Topic
Author Message
johnwsun
Senior Member
Senior Member


Joined: 28 May 2008
Location: Australia
Online Status: Offline
Posts: 179
Quote johnwsun Replybullet Topic: a formula calculation problem
    Posted: 21 Mar 2009 at 9:18pm
Hi
 
I have a report where there is a field  called value which is calculated in the below formula @get_value :
 
if {INX.ID} = "" and {CCY.ANSI} = "" then
   totext({ITD.PRC})
else if ({ILT.TYPE} = 'CR') then
            "( " + totext({@actual_inv_cost_S$})+ " )"
     else
          totext({@actual_inv_cost_S$})
 
This value is supposed to display value with brackets when this is the type of Credit, no bracket when there is Debit ( invoice type) associated
 
   so:
 
   Type     Invoice Cost           Value
 
    CR                                   (25.00)
    DB                                    35.00
    CR                                  (15.00)
    M                                      45.00
etc...
Now if I insert a Summary for subtotal of "Value" , I cannot get a correction result.
So I used a formula and put in the group head section and suppresed it:
(This forumla needs to take consideration of currency code for each record)
whileprintingrecords;
CurrencyVar acq_sub_amount;

if ({CCY.ANSI}) = "" then
   ccur(0.00)
     //acq_sub_amount := acq_sub_amount + {@get_value}
else if {CCY.ANSI} = 'USD' then
    acq_sub_amount := acq_sub_amount + ccur({@get_value})
else if ({CCY.ANSI}) = 'SGD' then
    acq_sub_amount := acq_sub_amount + ccur({@get_value})
else if ({CCY.ANSI}) = 'AUD' then
    acq_sub_amount := acq_sub_amount + ccur({@get_value})
else if ({CCY.ANSI}) = 'GBP'
 
 
another formula to handle the display of the subtotal:
 
whileprintingrecords;
currencyvar sub_value_amt;
 
The above approach didn't get a correct result either. the above should be $80.00.  How do I get rid of those values with brackets in the addup? could anyone please advise? thanks in advance.
 
John
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 23 Mar 2009 at 6:33am
you could add a local textvar gValue := {@get_value};
 
then add an if statement like:
if left(gValue, 1_ <> "(" then
 
that should do it.
IP IP Logged
johnwsun
Senior Member
Senior Member


Joined: 28 May 2008
Location: Australia
Online Status: Offline
Posts: 179
Quote johnwsun Replybullet Posted: 23 Mar 2009 at 4:16pm
Hi,
 
I have done something like the following, that still gives incorrec result:
whileprintingrecords;
currencyvar sub_value_amt;
StringVar gvalue :=  totext({@get_value});
 
if {CCY.ANSI} = 'USD' then
     if left(gvalue,1) <> '(' then
          sub_value_amt := sub_value_amt + ccur({@get_value}) 
else if ({CCY.ANSI}) = 'SGD' then
        if left(gvalue,1) <> '(' then
           sub_value_amt := sub_value_amt + ccur({@get_value})
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 24 Mar 2009 at 6:17am
Try unsuppressing the formula and see if gives the result that you think you should be getting.  I would think that this sort of formula would be in the details section of the report, but every report is unique.  Try moving the formula around and see if the results you are looking occur in a different section.
IP IP Logged
johnwsun
Senior Member
Senior Member


Joined: 28 May 2008
Location: Australia
Online Status: Offline
Posts: 179
Quote johnwsun Replybullet Posted: 24 Mar 2009 at 8:11pm

Hi, my logic in code was wrong, after I corrected it, result turns correct. Back to school!

Thanks very much!

IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.020 seconds.