Crystal Report Duplicating fields - crystal-reports

hello im freasher in Crystal Report, Im facing one problem that , I have two tables with data in ms access
1.employee 2.Purachse order
two employees are there
purchase order comes in three types A,B and C
so i need to see the count of A,B,and c for each employees.
lets say
EMP POcount type
Abi 2 A
1 B
0 C
Bibi 5 A
0 B
1 C
Like this how could i do this

{#Count} // Place the formula the group header and hide it
global numbervar code = 0;
{#IncrementBarCount} // Place it in group body and hide it
global numbervar code;
if <DATABASE_COLUMN> = "A" then code := code + 1
{#BarCount} // Place it where you want to see your result
global numbervar code;

Related

Crystal Reports - SECTION NAME - Is there a way to conditionally check or store the SECTION NAME in a within formula field

I would like to check in which section the formula is in and then conditionally return a specific value (either a database value or a calculated value) from the associated detail line data. Trying to avoid having to setup a separate formula for each detail section.
I tried setting up a loop counter but the loop counter never changes for same sections (details a, b, c, d, etc) only when the record number changes. I setup a Whileprinting formula (Init & Calc) without success
Header section - Global Numbervar N:=0;
Detail section - WhilePrintingRecords; Numbervar N; Global NumberVar N:=N+1
Again would like to setup a single formula that would return a different value based on which section its is in.
Formula would be something like...
"section Name" = Details a, Details b, Details c, or Page Header a, Page Header b, etc
If "Section Name" = "Details a" then
\\ Return Value 1
{NETSALES_TODAY}
Else if "Section Name" = "Details b" then
\\ Return Value 2
{NETSALES_MTD}
Else if "Section Name" = "Details c" then
\\ Return Value 3
{NETSALES_QTD}
Else {NETSALES_YTD}
EDIT: IT SEEMS IT DID NOT WORK - It is kept here for historical reasons (and because knowing it does not work is still valuable).
I think you were very close. I can't test it right now, but give it a try:
Create a formula like you did. Let's call it {#Declaration}.
global numbervar N := 0;
Create another formula like you did. Let's call it {#Increment}.
global numbervar N;
N := N + 1;
Put {#Declaration} in the report header.
Put the {#Increment} in the three detail sections.
Modify your formula to check the value of N mod 4 to be 0, 1, 2 or 3. Maybe you don't need the mod (just in case of many details rows).
global numbervar N;
if N mod 3 = 0 then {NETSALES_TODAY}
else if N mod 3 = 1 then {NETSALES_MTD}
else if N mod 3 = 2 then {NETSALES_QTD}
else {NETSALES_YTD}
The purposed differences are (1) put the formula 3 times and (2) a small correction in the formula itself.

Display number of rows on printout

If an Order contains 2 lines or more, my report sums it up and prints the whole quantity of items. It should print whichever line I have chosen:
WhilePrintingRecords;
NumberVar ItemCount := ItemCount + 1;
ToText(ItemCount, "0") & "/"
& ToText(Count({rpt_PackingSlip.LabelQTY}, {rpt_PackingSlip.WorkOrderNo}),0,"")
For example, the order below contains a chair called Buzz, but the order contains 3 lines since each has different fabric. The total order quantity is 5:
If I print, the label count shows 1 out of 4 - which automatically sums the chair. If I select the first line, expected output is Buzz 1/2.. and 2/2. Currently output displays Buzz 1/4.. 2/4.. 3/4.. 4/4.. even if I just clicked 1st line. How can I achieve this result?
You'll want to reset the counter on each group. Just create a second formula and drop it in the group header:
global numbervar ItemCount := 0;

Crystal Reports - Formula Workshop

I have created a crystal report which groups products based on order number.
I have created a formula which displays the text 'Partially Completed' or 'Fully Completed' based on whether a field on each product called 'Difference' equals 0 or not. If 'Difference' is 0 then 'Fully Completed' is displayed and vice-versa.
What I need to do is to display the corresponding message for the overall order number (i.e. if any of the products for an order have a difference != 0 then display 'Partially Completed'. If all the products have a difference == 0 for an order then display 'Fully Completed'.
This is the code I have attempted so far:
StringVar ouputText;
if {AD_999_SB_Fulfillment__Summary.FulfillmentPicking.Difference} = 0 then
ouputText := 'Full'
else
ouputText := 'Partial';
ouputText;
I assume I need some kind of for-loop to loop through all of the products for an order and check to see if any of the orders have a difference != 0 and then update the message based on if all the products have a difference == 0 or one of the products breaks the condition by having a difference != 0.
Looping is a lenghty process instead you group your report according to the "Order" then place the product in detail part. This will automatically loop entire products in a Order.
Create formula with name reset and place it in group header. Code is below.
Shared stringVar array y;
y:=" ";
join(y);
Create a formula and place it in detail section. This will take the result and store it in array for future use. Use below code.
StringVar ouputText;
Shared stringVar array y;
if {AD_999_SB_Fulfillment__Summary.FulfillmentPicking.Difference} = 0 then
y:= y+'Full'
else
y:= y+'Partial';
if {AD_999_SB_Fulfillment__Summary.FulfillmentPicking.Difference} = 0 then
ouputText := 'Full'
else
ouputText := 'Partial';
ouputText;
In group footer create another formula to display whether result is full or partial for order.
Shared stringVar array y;
if "Partial" in y
Then "partial"
else "Full";

Sumifs in Crystal

I'm working on a database that basically looks like this (in its simplest form):
{Phase} {Code} {Qty}
Example:
{Qty} for {Phase}="R" and {Code}="Nat" = 0
{Qty} for {Phase}="F" and {Code}="Nat" = 5
{Qty} for {Phase}="R" and {Code}="Int" = 10
{Qty} for {Phase}="F" and {Code}="Int" = 15
I am trying to get a result to show me the Qty for phase "R" and Code "Nat" (where R is <> 0) otherwise give me the qty for phase "F". So for the above example I would get an answer = 5 for Nat (because qty for phase R is 0) and an answer of 10 where the code is Int (because qty for phase R <> 0)
I have used three formula fields to do this:
1: if ({PHASE}="F" and {CODE}="NAT") then {QTY} else 0
2: if ({PHASE}="R" and {Code}="NAT") then {QTY} else 0
3: if {2} = 0 then {1} else {2}
Formula fields 1 & 2 come up with the correct amounts. However formula field {3} returns both phases. For example Code "Int" Phase "R" shows as qty = 25 instead of qty = 10.
How do I get around this?
You need to group by {table.code} because this is not a one-row calculation, but needs to be a calculation over each code for 2+ phases (meaning 2+ rows of data).
Create a formula with two variables that will store the values of each phase, F and R. This formula needs to go in the Details section of the report.
whileprintingrecords;
numbervar Fqty;
numbervar Rqty;
if {table.phase}="F" then Fqty:={table.qty}
else Rqty:={table.qty};
Now, in the group footer, you can reference both quantity values via the variables.
whileprintingrecords;
numbervar Fqty;
numbervar Rqty;
if Fqty=0 then Rqty else Fqty
And you're done. Don't forget to reset the two variables in the group header so you don't carry the quantity over between different codes.

Crystal report dynamic formula name

Here is what I have. I have 15 unique formulas named Week1, Week2, ... Week15. I would like to be able to take a parameter name, MYCount, and use that to loop through the records and sum them. So if MyCount is equal to 3, the loop would sum Week1 + Week2 + Week3. I know how to create a loop, but I cannot figure out how to build the formula name dynamically. Here is what I have so far: (I am using Crystal Xi)
Whileprintingrecords;
local NumberVar i := {?MyCount}
For i := 1 To (MyCount-1) Do (
i = {#Week & "i"} + i
);
x
I think you may be over complicating. Why not just do:
Local numbervar x := 0;
If param > 0 then
X := x + week1;
If param > 1 then
X := x + week;
And so on...
X;
I don't exactly what you are trying to do, but you may want to consider another approach.
Create a formula that will segment a field based on a date field's week number:
//{#amount}
// adjust firstDayOfWeek and firstDayOfYear parameters to match your organization's
// definition of a week
If DatePart("ww", {table.dateField})<={?Week} Then
{table.amount}
Insert a summarized field on the formula field.
If you are using your #Weekn formula fields so that you can summarise by date across the page, then have you considered using Crystal's Crosstab functionality instead?