Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Please Help Post Reply Post New Topic
Author Message
bkaukab
Newbie
Newbie
Avatar

Joined: 06 Jul 2011
Location: United States
Online Status: Offline
Posts: 10
Quote bkaukab Replybullet Topic: Please Help
     Posted: 06 Jul 2011 at 3:16am
Hi i am very new to Crystal Reports
 
Trying to make a crystal report from a view in sql server
 
data is coming into three rows and i need to manuplate it and make it one row with in crystal
 
i.e
 
Account               Amount                Flag
020                     1000                    Null           
050                     50                        D
050                     60                        I
 
i am getting these three rows , now with in a crystal reports formula
i need to add Amount with flag D (2nd row+first row) and than subtract 3rd row from 1st row to make it one number.
 
formula should be doing (1000+50-60)
 
Can some one let me know how to do that
Bill
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 06 Jul 2011 at 3:22am
do you have a consistent use of flagging, like always subtract "I" and add everything else?
If so make a formula field to convert your data into what you need for a SUM function
table.amount * if table.flag = "I" then -1 else 1
then sum that formula field
IP IP Logged
bkaukab
Newbie
Newbie
Avatar

Joined: 06 Jul 2011
Location: United States
Online Status: Offline
Posts: 10
Quote bkaukab Replybullet Posted: 06 Jul 2011 at 3:29am
yes flagging is consistent
 
if i did not get you wrong you want me to do something like this
 
If flag="I" then amount+amount where flag=Null ??????
Bill
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 06 Jul 2011 at 3:36am
no, I wanted you to create a fomula field that will look at the Flag field. If it is = to "I" then it muliplies the amount field by negative one (making it a negative value), if it is <> to "I" it multiplies the amount field by 1, basically leaving it a positive value.
if you place this formula field on your report design it would like this
Account               Amount                Flag         Formula
020                     1000                    Null            1000
050                     50                        D                50
050                     60                        I                 -60
 
Now if you do a SUM of that field it will add your records to together which gives you the value you want (adding a negative value is the same as subtracting).
you proabably need to alter this to handle NULLS in your records set to look like this
 
{table.amount} * (if isnull({table.flag}) or {table.flag} <> "I" then 1 else -1)
to insert a SUM click on the sigma sign, select the field you want to sum (the formula field you just made) set the calculation to SUM and the location to grand total (assuming you are not grouping).
it will look like this
 


Edited by DBlank - 06 Jul 2011 at 3:38am
IP IP Logged
bkaukab
Newbie
Newbie
Avatar

Joined: 06 Jul 2011
Location: United States
Online Status: Offline
Posts: 10
Quote bkaukab Replybullet Posted: 06 Jul 2011 at 3:42am
first of all thank you very much for the reply
 
i got your point.
 
But i dont need to show these three rows on my report. I just want to show that calculated number. so there is not going to be any grand total.
what i am doing is making a small summary level block by using cross tab and this calculation result will be shown in one cell of that cross tab.
 
 
 
Bill
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 06 Jul 2011 at 3:46am
you still have to calculate the rows. if you want to use a ct make the formula field and then use it in the ct as the summrized field.
Crystal does everything in rows. Even Crosstabs. They are basically a different way of viewing row level summaries, but still it is based on every row.
does that help?
IP IP Logged
bkaukab
Newbie
Newbie
Avatar

Joined: 06 Jul 2011
Location: United States
Online Status: Offline
Posts: 10
Quote bkaukab Replybullet Posted: 06 Jul 2011 at 9:27am
Bro i finally got the view
 
structure of data is something like that:
 
B.Unit             CYEAR         CMonth          QTY           Flag
3                    2011             1                  10
3                    2011             1                   2                D
3                    2011             1                   3                I
3                    2010             1                   15            
3                    2010             1                    4               D
3                    2010             1                    5               I
 
Challange is same , but now its not a cross tab its going to be one number in a free standing cell.
Formulla should bring all three rows of 2011 and then there needs to be a calculation where Qty next to blank flag 1st row is getting subtracted by 2nd row having flag value D and Getting increased with value of QTY for flag I 
can you please type that formula by using the uppers schema i have done almost every thing but not getting it
Bill
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 06 Jul 2011 at 9:44am

So you need to show the incrimental row level changes and D values are to be subtracted and you need to reset your total each time Cyear changes?

Create a formula field to get your positive and negative values (convert your D's to negatives).
I am calling this formula 'PosAndNeg'
{table.amount} * (if isnull({table.flag}) or {table.flag} <> "D" then 1 else -1)
Create a Running Total
Name = cYearTotals
field to summarize = @PosAndNeg (your new formula field)
type of summary = SUM
Evaluate=For each Record
Reset = On change of field (select the Cyear field)
place this on your detail row and you shouldget this
 
B.Unit             CYEAR         CMonth          QTY           Flag     Total
3                    2011             1                  10                           10
3                    2011             1                   2                D           8
3                    2011             1                   3                I            11
3                    2010             1                   15                           15
3                    2010             1                    4               D           11
3                    2010             1                    5               I            16
IP IP Logged
bkaukab
Newbie
Newbie
Avatar

Joined: 06 Jul 2011
Location: United States
Online Status: Offline
Posts: 10
Quote bkaukab Replybullet Posted: 06 Jul 2011 at 9:56am
ok your formula is doing correct work .
 
but i dont have a detailed section it is going to be one single block
 
with 4 columns and 1 row , i am using free standing cells to make that table
 
now whatever you have done is fine but it will add one column in the detailed view. and i want to have one number which will be in a free standing cell just one number out of 3 rows of 2011
 
can i email you the structure
shoot me an email if you dont want to publish you id here
Bill
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 06 Jul 2011 at 10:23am
sorry , don't accept files.
you can suppress items if you want
next(table.cyear)=table.cyear
 
or use a group footer
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