Remove a field from details in Crystal Reports fo SUM - crystal-reports

Here is my crystal report PAY_DETAILS data field.Here I need to remove/suppress the CBS field and its value when I am getting the total.
Amount Earn_Type
-----------------------
100 ER006
200 ER007
300 ER009
400 ER003
500 ER004
1000 CBS
600 ARS
-----------------------
2100 Total
So when the view should be as follows.I tried it with suppressing the field with the suppressing condition
if({PAY_DETAILS.EARN_TYPE}="CBS")
But even it hides it comes to the Total
Amount Earn_Type
-----------------------
100 ER006
200 ER007
300 ER009
400 ER003
500 ER004
600 ARS
-----------------------
3100 Total

create a formula maybe call it Amount
if {PAY_DETAILS.EARN_TYPE}="CBS" then {valuefield} else 0
place that in the details and creat a total from that instead of the database field.
In your suppression area use
{#Amount} = 0

Related

Adding a column based on other columns KDB+

I have a table ("ibmqt") with a number of columns, and I would like to add a new column, containing boolean values indicating for each row whether one column ("bid") is greater than or equal to another column ("ask").
My most successful attempt so far is this:
ibmqt: update (pricecross:select bid>=ask from ibmqt) from ibmqt
However, this results in the following:
time sym bid ask bsize asize pricecross
----------------------------------------------------
00:00:59.063 IBM 43.53 43.57 10000 9000 (,`ask)!,0b
00:01:03.070 IBM 43.54 43.59 6500 3000 (,`ask)!,0b
00:02:31.911 IBM 43.56 43.6 500 4500 (,`ask)!,0b
00:03:43.070 IBM 43.56 43.56 10000 2500 (,`ask)!,1b
00:06:01.170 IBM 43.54 43.56 8500 4500 (,`ask)!,0b
00:06:11.081 IBM 43.56 43.58 500 1500 (,`ask)!,0b
00:08:15.126 IBM 43.55 43.57 1500 9000 (,`ask)!,0b
Obviously in the "pricecross" column I just want 0, 0, 0, 1, 0 etc.
Any suggestions?
There is no need for a nested select. This will do what you need:
ibmqt:update pricecross:bid>=ask from ibmqt
Or you can update ibmqt in place:
update pricecross:bid>=ask from `ibmqt
q is an array language, therefore bid>=ask compares two columns pairwise and returns a list of booleans. This will illustrate the idea:
1 2 3 >= 0 2 4 / 110b
The list of booleans is then assigned to a new column pricecross.
since >= is overloaded to work with both atom and list, using pricecross:bid>=ask is the best solution here :
q)update pricecross:bid>=ask from ibmqt
But there is a slightly different way of getting the same results :
q)update pricecross:bid>='ask from ibmqt
q)update pricecross:>='[bid;ask] from ibmqt
This is particularly useful when the dyadic function works only with atoms :
q)update pricetolerance:tolerance'[bid;ask] from ibmqt

Script editor in crystal report

How do i use script editor in crystal report to subtract two fields in the footer
For Ex:
i have one table called "PAYMENT" and it has two fields
1> "order amount" and
2> PAYMENTAMOUNT
ORDERID PAYMENTID PAYMENTAMOUNT ORDERAMOUNT
ABC 1 100 500
ABC 2 200 500
in crystal report, i have added one field which describes the code as
DUE = ORDERAMOUNT - PAYMENTAMOUNT
for the above code, it brings the value = 400 & 300 for each record
i need add one field which shows the sum(ORDERAMOUNT) and sum(PAYMENTAMOUNT) and the final result is 500 - 300 = 200
please help

Crystal Report Cross Tab Calculated Member as text

I'vre created a cross tab report with 2 calculated Member to be able to have the difference between 2 column and the percentage of this difference in CR 2011. What I want to achieve is to create a new column that will display a test depending on the difference value.
Here is a example:
Col1 Col2 Difference Percentage Action
200 0 -200 100 DROPPED
100 100 0 0
0 300 300 100 ADDED
How can create this action column. Calculated member only want some amount value so I cannot output a text in the formula.
Thanks in advance for your help
I finally found the solution.
I can use the Display string formula in the Format Field properties (Common Tab). Here I just check the column and return the string I want otherwise I just format the number.
IF GetColumnGroupIndexOf(CurrentColumnIndex) = 1
AND CurrentColumnIndex =4 THEN
IF GridValueAt(CurrentRowIndex, CurrentColumnIndex,CurrentSummaryIndex) =2 THEN "DROPPED"
ELSE "ADDED"
ELSE
ToText( GridValueAt(CurrentRowIndex, CurrentColumnIndex,CurrentSummaryIndex),2,",")

Stop Crosstab summary display string count from Resetting on each page

I have a crosstab in Crystal Reports XI with a display string that displays a count for each time the condition is met:
Basically I have a summary column amountspent that I need to compare to avblcredit, and count every order where amountspent (the summary) exceeds avblcredit for each group, customer. I then have to display the total amount of orders for that customer where available credit is exceeded.
After much struggle due to the fact that I cannot use calculated members in Crystal Xi. I
created a second duplicate summary for item exditures and edited the display string of the second summary to compare itself to avbl credit then count:
global numbervar count;
if currentvalue > avblcredit
then count := count + 1;
count;
The count then increments everywhere it finds the current value (sum of items) > available credit.
This works correctly if the crosstab prints fully on the page, however if the crosstab extends to the next page the count resets back to 0.
So basically as an example page 1 looks as follows:
customer 1
orders avblcredit amountspent count itema itemb itemc
ord1 4000 6000 1 2000 3000 1000
ord2 3734 5001 2 1000 2000 2001
ord3 4123 5000 3 4000 1000 0
ord4 2321 5000 4 5000 0 0
ord5 4000 5003 5 1200 3800 3
ord6 4000 6000 6 1000 2000 3000
page 2 with customer 1 group continued:
orders avblcredit amountspent count itema itemb itemc
ord7 4000 6000 1 2000 3000 1000
ord8 3734 5001 2 1000 2000 2001
ord9 4123 5000 3 4000 1000 0
ord10 2321 5000 4 5000 0 0
My question is how can I get my count from resetting on each new page?
Thanks
If you can modify your datasource, you can do the calculation upstream. Just extend your existing dataset with a new field named something like spentExceedsCredit with a value of 0 or 1. Then you can sum them per customer, or use custom formatting in the report, or have the list of customer expenditures exceed a page, or whatever, and you're not dependent on Crystal's global variables.

How to avoid the duplicate count

Using Crystal Report 7
ID Total
001 100
001 100
002 200
002 200
003 300
003 300
Formula for supressing the duplicate value
if {table1.ID} = previous({table1.ID}) then true else false
The above formula is working, but i want to sum of total value, when i use sum({table1.total}) = 1200, It should show 600 instead of 1200
Expected Output
ID Total
001 100
002 200
003 300
-------
600
How to get a exact total.
Need Crystal report formula help or suggestion
You should really address the underlying issue. Why are the rows being duplicated? I suspect there are additional columns you haven't shown us.
Alternatively you can:
Group by ID, then use a running total set to evaluate on change of group
Use a running total set to evaluate using the opposite condition to your suppression formula {table1.ID} <> previous({table1.ID})
P.S. You can write if {table1.ID} = previous({table1.ID}) then true else false as {table1.ID} = previous({table1.ID})