I have below data in my detail section.
Contract No
VTC/2013/0026
VTC/2013/0028
VTC/2013/0030
These data are belong to a one field in a table and there can be more.
I want to display the same details in the report header like below.
VTC/2013/0026, VTC/2013/0028, VTC/2013/0030, ...
How can I do that without using a sub-report?
Follow below steps:
Create a formula Concat and write below code and place in right most part of the report.
Shared Stringvar a;
a:=a+Contract No+", " ;
now create one more formula display and place in report header.
EvaluateAfter(#Concat);
Shared Stringvar a;
a
Related
I want to get sub report to main report value pass. How this possible?
this is my main report and My Need format
And sub report is-
this is my Sub report
AVGQty formula is - Sum ({Command.IssueQty})/Sum ({Command.WorkingDays})
I want to get every Item Wise average from sub report in main report using report link.
as like, Acetic Acid - AVG Qty: 128.91 (Item wise value come from sub report)
You need to use a shared numbervar in your formula.
In your case:
shared numbervar AVGQty:= Sum ({Command.IssueQty})/Sum ({Command.WorkingDays});
then in your main report you simply create a formula with:
shared numbervar AVGQty
From what i understand, you don't need callback value (shared variables) from subreport in your main report. Just include subreport dataset into your main report and link those 2 tables in database expert.
So for example you have table a which is in your main report and table b which is you subreport. You link them from itemname from table a to itemname to table b. To make this without any shared variables you should just add table b to main report, in database expert link both tables with itemname and then you can group by attribute itemname from table a to get summarizes which you want.
You can do it with shared variables or with this logic. Your choice
Hope it helps
I have a simple report that can display many detail rows.
I want to target a specific row and use it's values to populate aspects in the Report Header and Footer.
For example , I know what the minimum(primarykey) within the detail rows that I display.
A simply formula can capture that.
I want to pick up other attributes of the row with the minimum(primarykey) and display in the header or footer.
I therefore want to select a specific row select and use its data in the header and footer, something like:
Select NAME, DATE from DETAILSROWS where DETAIL.PRIMARYKEY = minimum(DETAIL.PRIMARYKEY)
I've thought about using a subreport here, and passing values back to the main report, but that doesn't see to the way to go... I've tried for example passing minimum(DETAIL.PRIMARYKEY) to the subreport so that the sub loads only the row I want, then passing the values back via shared variables. But I don't want to display the subreport, and if I suppress it, my shared variables don't seem to populate.
Displaying the values in the Report Footer would be easier than the Header. All you'd need to do is compare each row's primary key to the value of maximum({DETAIL.PRIMARY_KEY}) and save off the values. So something like:
stringvar saved_column1;
stringvar saved_column2;
if {DETAIL.PRIMARY_KEY}=maximum({DETAIL.PRIMARY_KEY}) then
(saved_column1 := {DETAIL.COLUMN1};
saved_column2 := {DETAIL.COLUMN2})
For the header, really the only way I can think of is to use the subreport like you're already doing. I'd just format the subreport to display itself, though, and not mess around with shared variables.
Okay so it turns out the SUBREPORT option is the way to go.
SUBREPORT is a bare minimum report that has passed to it, the lookup value you are after.
Long winded, I link to it using a formula that holds essentially: minimum(DETAIL.PRIMARYKEY).
In turn the subreport selects that single detail record.
Within the subreport, build a Formula and drop it the into its report header:
WhilePrintingRecords;
Shared DateTimeVar subCreationDate := {DETAIL.CREATIONDATE};
Shared StringVar subCreationName := {DETAIL.CREATIONNAME};
Finally, suppress all the the sections (delete what u don't need) on the SUBREPORT, and close.
On the main report... Not sure but it looks like the SUBREPORT can sit anywhere.
And because you've suppressed elements WITHIN the SUBREPORT, it won't display on the main report.
(So no need to suppress on the main report - and if you do suppress it there, it won't work anyway!)
Now create your formulas (in my case 2) on the main report and in each, repeat the variable declaration.
Shared DateTimeVar subCreationDate
Shared StringVar subCreationName
Again, each of the above sit in their individual formula declaration.
And from there, you now have "standard" formulas to work with on your main report.
They can be referenced just like any other!
Thx Ryan - your answer certainly helped me get where I need to go - u still get my +1!
I have a very basic report with no groups. The details consists of a number of numeric columns. I want to add a formula field which will use a field from the first row. Example:
(ColumnAFromCurrentRecord - ColumnBFromFirstRecord) / ColumnBFromFirstRecord
Can someone point me in the right direction?
1.
Create a formula named AssignFirstValue and define it like this:
WhilePrintingRecords;
Global StringVar strFirstValue := {MYDBNAME.MYSTRINGFIELD};
Put the AssignFirstValue formula in your Report Header and suppress it.
2.
Create a formula named PrintFirstValue and define it like this:
WhilePrintingRecords;
Global StringVar strFirstValue;
strFirstValue
Put the PrintFirstValue formula wherever you want to display the first value in your report.
you need to extact the column b from first record. try below solution.
Note: This is not a tested solution as I at present I don't have CR.
create below formula Count and place in detail section:
Local NumberVar a;
a:=a+1;
This will number the rows starting from 1 to the last row.
Now create one more formula StoreB:
Share NumberVar b;
if {#Count}=1
then b:=columnb
This will store the value of columnb in first record in variable b
Now use where you want:
EvaluateAfter(#StoreB)
Shared NumberVar b;
(ColumnAFromCurrentRecord - b) / b
Let me know how it goes.
Hi I want to store sub report fields per page into an array and print that array inside the report footer in main report. Any clue guys ?
If you're talking about only a few fields, then I'd recommend a shared variable taking the data back to the main report.
If it's alot of data, then you should make another subreport in the main report's footer and calculate all your data there.
Edit
Well, you asked, so here's how:
In your main report's footer, create a formula (call it FooMain) with this code:
whileprintingrecords;
shared stringvar MyLittleVar;
In your subreport, create a formula (call it FooSub) with this code:
whileprintingrecords;
Shared stringvar MyLittleVar:="This is from the subreport";
Preview your report. In the footer, the FooMain formula should display "This is from the subreport". Use FooMain in whatever calculations in the main report. Due to fundamental design aspects of Crystal, this will only work if FooMain (and any formulas that reference it) is below the subreport it is getting data from.
Using Crystal Reports I'm trying to display the running total of a database field in the header where all the labels are.
I've attempted to do this by placing the running total (RTversion) into a formula field with the following:
Shared stringvar CurrentVers;
CurrentVers := {#CurrentVers};
and then in the page header section I have the following:
Shared stringvar CurrentVers;
EvaluateAFter({#currentVers});
CurrentVers;
with {#CurrentVers} running the 1st largest number.
Is this incorrect?
Update: The goal is to display the latest version in the header near the labels to show what the current verseion is for comparison.
Running-Total Fields, in my experience, only work in the footer sections.
You will need to create a manual running total.
Add a formula field to the Details section that populates a Global variable with whatever you are trying to capture. Something like:
//use WhileReadingRecords if the values can be gathered as the report pulls in values from the database. Otherwise, use WhilePrintingRecords.
WhileReadingRecords;
Global Stringvar CurrentVers;
//logic here to capture what you want
CurrentVers:=...
Add another formula field to the Header section. Add these two lines to it:
WhilePrintingRecords;
Global Stringvar CurrentVers;
Create a formula like this
formula = Count ({Field to count},{GroupFieldName})
and place it in group header section.
I figured it out..
I had to add a subreport to the main report. I copied the main report and renamed it as a subreport. In the subreport, I added a shared variable and then passed it to the main report. The trick is to place the subreport in the same group header, but a separate section above the section that needs to be suppressed. I actually added the following sections:
New section (same group-I placed subreport here; do not suppress)
New Section (same group - I placed shared variable value here; do not suppress)
Original Section (same group that has a header I need suppressed based on a running total)
If {#CurrentVers} is a regular running total field, you should be able to place it in the page header directly rather than resort to an additional formula. I don't see the need for either formula field here, unless there's something unusual in the composition of {#CurrentVers} and a 'largest number' running total shouldn't require anything out of the ordinary.
You can solve this with just one formula field:
WhilePrintingRecords;
// Enter logic here e.g.
// maximum({mytable.myfield});
The WhilePrintingRecords; forces the formula to not be evaluated until all records have been read from the database, and therefore the formula field will display the correct result even if placed in a header.
The key I found is that the formula field being passed needs to be placed on the subreport. I placed mine in the footer then suppressed it.