Can I set conditions for how values display? - crystal-reports

I'm not sure if this is the best way to ask the question, but I can't think of a better one. I am new to Crystal Reports and have been basically left to figure it out on my own with just some resource books and YouTube.
My issue is this: I am building a report for a school that displays the next year's course selections. The report is pulling the values from an online form the students fill out and displays results on the report with two names, let's call them "report.name" and "report.value". "report.name" is an arbitrary value that the HTML of the form uses. I am wondering if it's possible to give Crystal a set of conditions so that I can format the way it displays to be a little cleaner.
Example:
CurrentMathClass Geometry
NextYearsMathClass Algebra 2
ElectiveChoice1-Grade10 Spanish 1
Right now the report is showing it like this because those are the values it is seeing. I would like it to be like this:
Current Math Class Geometry
Next Year's Math Class Algebra 2
Elective Choice 1 Spanish 1
Is there a way to give CR a set of conditions that tells it to print something different when it sees specific values, without removing the 'Name' field from the report?
Sorry if this questions is all over the place, I'm having a tough time organizing my thoughts. I appreciate any and all help.

Look to the right of Crystal. You'll see "Formula Fields".
Create a new formula. Call it #namechange or something.
If {report.name} = "CurrentMathClass" Then "Current Math Class".
Drag that formula object onto the report.

Related

Multiple copies of a record based on formula

Good afternoon,
I am very new to Crystal Reports, so am not sure where to look for this information and would appreciate if someone can point me in the right direction or tell me if what I am asking for is impossible.
One of our departments uses a field called RecordChanges to note changes made to a record. The field is text and the department stores information there about the date a change is made and the type of change, separated by commas (i know this is terribly inefficient, but it's what I have to work with). I have a Crystal Report that parses this text field and picks up the latest date and latest change made to the record. I would like to modify this report to include ALL the changes made to the record, so if the field RecordChanges of the data source has 3 dates, I would like this record to appear in my Crystal Report 3 times, once for each change that was made. How to parse the field I can figure out but where I'm stuck is how do I make the number of times a record appears equal to the number of dates found which is my {#DateFound} field?
There is a lack of details, but as far as I understood the problem and assuming that you did state in the comment that "there wouldn't ever be more than 5 changes to an order", here is a first try to tackle the situation.
I will assume that you already have a formula that "parses this text field and picks up the latest date and latest change made to the record". And that you know how to adjust this formula to pick up each of the record changes. I will name this formula as {#Parser1}.
Based on {#Parser1}, create other 4 formulas: {#Parser2}, {#Parser3}, {#Parser4}, {#Parser5}. As you probably presume, each formula must be changed to parser the Nth occurrence of the record change.
Create 5 details sections.
Put each formula in each detail section.
Suppress the detail section wich formula is null or empty.
That's it.
The limitation is that you can have at most 5 record changes.
This is an awkward solution, but it is necessary (as far as I know) since Crystal Reports works based on your data rows. It iterates over the rows, but cannot "generate" more rows by itself. If you can manipulate the data source, you can create other solutions.
You still need to do the magic trick to pickup the Nth change from the text.

How to make the following report using Jasper Reports

I collect test results between different locations. I can never predict the amount of locations that I should generate the report for and I need to make a dashboard representing these results. The dashboard should look like this (Assume a tabular structure):
Title
Report info 1|Report info 2
Conditionally displayed report (info 3) spanning the whole table columns
Report info 4|Report info 5
Blank Cell|Location A|Location B...etc
Location X|X-A result|X-B result...etc
Location Y|Y-A result|Y-B resutl...etc
.
.
etc
I've read A LOT and after a lot of reading I still don't think I can start making a JR report !
Although, after a while of chasing the solution of doing so using tables, I found that I should use crosstabs instead because tables aren't dynamic enough (i.e. since I can't predict the amount of rows\columns that will need to be displayed). But then after reading the crosstabs section I found that it's purpose is to summarize results, like calculate totals, averages, minimum and maximum..etc and still, that's not what I need. I'll have to provide all the results locations on the x\y axis and their results, no SQL will be involved.
Also what data structure would be suitable for that ? A datasource ? A java collection\object passed as a parameter ?
Any idea how can I do that with JR ?
Also a I'm finding JR VERY confusing and complicated. I was very happy to read the freely available ultimate guide and check the demos but that didn't help much, it still looks very complicated !
Thanks in advance.
if you cannot predict the amount of columns, crosstabs are the elements you have to choose. But be aware, that the width of a Jasperreport is static (and like this possibly not optimal for your purposes).
A crosstab will summarize your data only, if you have a column or row label twice, and only if the data is not sorted by the crosstab itself or by your datasource.
According to your description, I would use a report layout like
Title-Band: Title, Infos etc
Summary: Crosstab
You could pass the static title content as parameters into your report, the crosstab content as a datasource (e.g. a bean collection)

How to suppress specific bar on bar graph in crystal reports?

So I am trying to suppress a specific bar on my bar graph. So instead of populating the graph from the database, I am populating it from a formula field. So in my formula field, I have something like this:
if field <> "Member" then
formula = field
So it gets rid of the field however it leaves me with this:
I know I can make a subreport that gets rid of that field from the beginning, but I was hoping to avoid creating a subreport for this.
Any ideas? Thanks!!
Instead of leaving the group name as blank when the field is "Member", I suggest changing it to be the same as another group which you can always expect to appear on the report - perhaps "SR not handled timely".
This would lump in all the member values with the other group's values, so if you haven't already done so, I suggest graphing the value of a derived field which is set to 0 for "Member". (I suspect you have already done this, as the blank group is showing a value of 0.)
The least error-prone method is probably the subreport. If this report is very dynamic, and you always want to hide group A in the graph regardless of it's value, then this is the best way to go.
If a static number of groups will be appearing in your graph, you can limit to display the top N groups. i.e. If there are 7 groups total, and you only want to hide 1 of them (which always has a value of 0), then you can display the Top 6 groups (picture is of Crystal XI):
Thanks for all the help guys, the data will be pretty dynamic.. So I am going to go with the subreport. I will add those little tricks to my toolbox though! Thanks again.
Alternatively, you can set a "specific order" and only include the values you want to include in your graph. In the "Other" tab you need to select "Discard all others".

Crystal Reports: Cross-Tab Column Arrangements

I am looking for a way out in cross tab, so that if the columns exceed in cross tab, they shouldnt go on next page..rather a new cross-tab should repeat after the first one.
For example, two columns are displayed in a cross tab :
Now if a new column is added, and assuming that it could not be accomodated within the given page width limit, it will go to a page next to it in CR by default.
But in my report it is required to be shown below the first cross tab (and not on next page), which will look as follows:
Please do suggest me if there's a way out :)
Thanks in advance
Your question is perfectly reasonable, but I'm pretty sure that in CR-XI, there is no automatic way to do this. I recommend skipping the cross-tab designer completely and just making your own:
Make a new CR using a placeholder table that has exactly 1 record.
In this CR, suppress everything but the details section. Add a new details section so you will have Da and Db.
In Da, add a subreport. Use your real datasource and add Column1 and Column2.
In Db, add a subreport. Use your real datasource and add Column3 and Column4.
I don't have time to test this, but I think it will display all the columns as you requested.
(Instead of step 1, you can probably use a placegrouper group in your report that only has 1 group. Then, when you add the subreports, make sure to not add any links to the main report.)
Edit
A dynamic number of columns makes this request much more difficult to do in Crystal.
Maybe you could autogenerate the entire report from a script. I couldn't help you with that, but I'm sure someone else on StackOverflow will.
You can use MS Excel to achieve something similar. Use MS Access or something similar to set up a crosstab of your data. Open a new Excel workbook and import your crosstabbed datasource using Data->Import External Data->Import Data (this imports the entire table, regardless of number of rows). In Page Setup, change settings to Fit to (blank) pages wide by 1 pages tall. You can format the data however you like and the format will be retained. This Excel method will squeeze all your columns into a 1-page wide area. It's not quite what you're asking for, but it will work.
The number of columns may be dynamic, but do you know what the field names could be? For example, your columns include 0-50 US States, then you know what the column names will be, just not which ones or how many. If this is your situation, then use my first suggestion (check off the suppress if blank options to hide unneeded subreports). It won't be pretty (alot of white space), but it can get the job done.
A possible solution can be a multi column report. But it can be difficult to make the row labels and values in the same line.
If you can create an additional row grouping then you have the solution that you want. For example if your columns have number like in your sample. Then you can add a formula like:
columnId \ 2

crystal report problem

what is the equivalant command like in vb for EOF(), MoveNext, Moveprevious commands in crystal reports
There are no equivalent answers in Crystal Reports, at least not in the versions I have used. Crystal Reports more or less simply dumps the data out into the report.
That said, if you are in a detail row, and you want to find out what the next value of a field will be, you can use:
next({YourColumn})
You can also find out the previous column value by using this:
previous({YourColumn})
Keep in mind that Next() won't work on the last record, and Previous() won't work on the first record.
I'll have to double-check, but I believe there is an OnLastRecord function that returns TRUE if you are on the last record.
First, welcome to SO!
Second, you sound new to Crystal Report's purpose is to display data, not perform the kind of calculations you're talking about. CR usually goes record-by-record through the data, displaying (or suppressing) each record, and adding group headers & footers.
To answer your question, LittleBobbyTables does give a few good pointers. To see the entire list of functions available to you, there is a list in the Formula Editor (see pic below). Press F1 for detailed descriptions of each command.
You can also:
Create a "Running Total Formula" that will evaluate each record and give a calculation in the group footer.
Do the calculations outside of Crystal Reports and only feed the end result in (perhaps with an unlinked join to your primary table).
The most complex option is to make a subreport that does the calculation and feeds the result back to the main report
Can you give us some more details about what you're trying to do?