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
Related
I have a report with a list of orders and their product lines
the order lines have Qty ordered, Qty Delivered and Qty Backordered.
the Group header is the Sales Order number, the Details are all the product lines on that sales order.
I want to calculate in the Report footer the count of all Sales orders that have a backorder on them only.
I can do "if sum of backorder <> 0 then 1 else 0" in Group footer, but i cannot sum the result of this, i get "This field cannot be summarized" because you cannot sum a sum.
is there another way i can achieve this?
for example:(report sample)
this example should be 1 in the report footer because only one of the orders has a backorder.
thanks
Create a new formula with following content and name it #SalesWithBackOrder (The formula doesn't need to be placed anywhere on the report):
If {backorder} <> 0 Then
{SalesOrderNumber}
Else
0
or if {SalesOrderNumber} is text then:
If {backorder} <> 0 Then
{SalesOrderNumber}
Else
""
Then count the number of distinct values of the #SalesWithBackOrder formula.
You can do this by creating a new formula with following content (put it in your report-footer):
DistinctCount ({#SalesWithBackOrder})-1 // -1 because order-number "0" respectively "" is a distinct value too.
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
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,",")
I need to work out the percentage in SSRS for the below data - sum the "Qty" of products where the Status = "Live" and then divide the it by the total "Qty" for all products:
Is it possible to this in SSRS expression or do I need to this in the sql query?
Weeknum___Status_____Qty
34__________Toxic______ 99
34__________ EOL______ 1819
34__________Live_______3440
34__________BER_______361
34__________Live______1
34__________Live______386
34__________BER_______39
34__________EOL______498
Fisrt you will have to create a metrix that filter the status maybe like this
=Fields!Status.Value
Then in another colum you will have to put this
=FormatPercent(sum(Fields!Qty.Value)/(Sum(Fields!Qty.Value, "YOUR DATASET"),1)
And you will get the percentages over the total of the Qty
I'm using Crystal Reports XI.
My data is coming from a dataset.
I have 2 tables which are related as follows:
Product(ProdID(PK), ProdName)
ProdPC(ProdPCID(PK), ProdID(FK), PCType, ProdCode)
The 'PCType' field determins the type of barcode format the 'ProdCode' represents. (E.g. EAN13, EAN8).
In crystal reports one 'Product' can have more than one kind of barcode which means my tables end up looking like this:
Product: ("1", "Example Product 1")
ProdPC: ("0", "1", "EAN8", "01234567"), ("1", "1", "EAN13", "012345678910")
In crystal reports I only want to print 1 barcode label for per product. However because they're are 2 records in the 'ProdPC' table, I will get 2 labels being printed for this 1 product.
What I want to do is place a condition in crystal reports which states, "If EAN13 is NULL then display EAN8, ELSE display EAN13"
I do not have access to the dataset and cannot prevent the application which calls Crystal Reports to create the barcode labels from sending more than 1 record for the 'ProdPC' table.
How can I create my conditional statement, purely in 'Crystal Reports 2008'?
What I have tried so far is:
IF {PartPC.PCType} = "EAN-13" AND {PartPC.ProdCode} <> "" THEN
{PartPC.ProdCode}
ELSE
/* DISPLAY PartPC.ProdCode containing EAN8 value */
;
But I am unsure how to then tell Crystal Reports to display the 'ProdCode' value where 'PCType' is equal to 'EAN8'
Group your report by Product ID.
Order your report by PC Type descending (within Product ID).
Include your report details in the Product ID footer (not the details section).
Option I: create two columns: one for each bar code. Do this in Crystal Reports.
Remove the PartPC table, replacing it with two SQL Expression fields:
// {%EAN-8}
(
SELECT ProdCode
FROM PartPC
WHERE ProdID=Product.ProdID
AND PCType='EAN-8'
)
// {%EAN-13}
(
SELECT ProdCode
FROM PartPC
WHERE ProdID=Product.ProdID
AND PCType='EAN-13'
)
Then create a formula field to display the appropriate one:
// {#barcode}
If Not(Isnull({%EAN-13})) Then
{%EAN-13}
Else
{%EAN-8}
Option II: alter the SQL to create to scalar-valued fields. Do this in your dataset or in a Command object (Crystal Reports).
SELECT Product.*,
(
SELECT ProdCode
FROM PartPC
WHERE ProdID=Product.ProdID
AND PCType='EAN-8'
) EAN_8,
(
SELECT ProdCode
FROM PartPC
WHERE ProdID=Product.ProdID
AND PCType='EAN-13'
) EAN_13
FROM Product
...