Jasper Report - Format Crosstab - jasper-reports

From a query, I get this data (simplified):
Referring Date Name Budget
2017-01 JACK 100
2017-01 JOHN 200
2017-01 SMITH 150
2017-02 JACK 50
2017-02 SMITH 200
2017-03 JOHN 300
2017-03 SMITH 200
2017-03 JENNY 150
I need a crosstab to organize budget on columns and referring-date and name on rows.
Using Jasper Wizard, I got this:
As you see, Referring Date is put in a Rowspan.
Unfortunally, Im requested to build something like this:
I've tried to modify Crosstab but when I try to move Referring Date above Name (companyName in my case) I got the error because Im "invading" company section.
Is there a solution?
Thank you!

Yes its possible. Don't use Cross tab. Learn and use report Group. Create group on "referring date".
For Total create a variable of data type same as $F{budget}.Set the Calculation to 'Sum', the Reset Type to 'Group' (and pick the appropriate group from the dropdown), set the variable expression to $F{budget}.

Related

Distinct count not giving expected result

I have fields for customer names, customer account numbers, date of previous orders, and order values. I want an alert to show which customers have ordered at least three times over the reporting period. We can have more than one invoice for a given delivery. The main report looks like:
Account Number Acct Name Order Date Order Total
1001 Fred Smith 1/2/2016 £1.06
1001 Fred Smith 1/2/2016 £2.34
1001 Fred Smith 8/2/2016 £5.42
2001 Aled Jones 1/2/2016 £2.90
2001 Aled Jones 8/2/2016 £3.45
I've tried concatenating the account number and order date in a column via function and running an alert based on its distinct count. (After converting the date to a string.) But it still doesn't generate a list of distinct items.
What I currently have in the final column is a function that concatenates the date and account number to give a unique field with {ORDR.CardCode} + Cstr({ORDR.DocDate}) - Which returns:
1001 1/2/2016
1001 1/2/2016
1001 8/2/2016
2001 1/2/2016
2001 8/2/2016
I want to generate alert based on this field via the distinct count function and a report of any customer who ordered at least twice in the report period.
DistinctCount ({#Concat code and date}) >2
Even after this I still don't get what I need. How can I get a list of every customer who has ordered in the report period for at least two times?
You have travelled half way... to achive continue from here.
USe the created formula {ORDR.CardCode} + Cstr({ORDR.DocDate}) to create a group.
place same formula in details and take count of the records in group footer
Now create a alert on group footer summation to get the desired result
Edit........
Since you need customer then add customer in concat fornula and then create group.
acctnamr+{ORDR.CardCode} + Cstr({ORDR.DocDate})
Now place the customer name in group header and follow process as explained above

How to create report in the format Like this?

I have been searching on the web for a while but couldn't find a solution.
I want to use JasperReports for a format like this:
--------------------------
Name:
Address:
Phone #
-------------------------
Domain Total Price
www.a.com 100 7500
www.b.com 150 1500
--------------------------
Type Total Price
Hosting 350 3500
Surfing 175 2200
--------------------------
It's just like if I need multiple Detail bands, I can create multiple Detail bands but the problem what I have is, I want to show the Column Titles only once, so in the case of (Domain, Total, Price) I can do it by placing them in the Column Header band but I can not find any luck for the other Detail band (Type, Total, Price)
Any help will be greatly appreciated.
Update: The dataset is presented in this way:
Type Domain Total Count
null www.a.com 200 30
null www.b.com 100 95
Hosting null 300 65
Surfing null 100 25
Given the structure of the dataset as posted in the comment:
create a report group based on this expression $F{domain} == null ? "Type" : "Domain"
in the group header add a text field with expression $F{domain} == null ? "Type" : "Domain" and 2 static texts for Total and Price.
in the detail band add these text fields with expressions:
field 1: $F{domain}==null ? $F{type} :$F{domain}
field 2: $F{total}
field 3: $F{count} * $F{total}
in group footer add the line
Done.
Assuming that there are 2 results sets:
add for each results set a sub dataset (i.e. datasetDomains, datesetTypes)
add a (fake) report group (i.e. with group expression null)
add in the group header 3 static text fields containing Domain, Total, Price
add below these fields a List item containing the fields of datasetDomains.
add below the list a line, configure it with Position Type Fix Relative To Bottom.
add in the group footer 3 static text fields containing Type, Total, Price
add below these fields a List item containing the fields of datesetTypes.
add below the list a line, configure it with Position Type Fix Relative To Bottom.
If your resultset was structured like the following, things would be easiest:
Type Detail Total Price
---- ------ ----- -----
Domain www.a.com 100 7500
Domain www.b.com 150 1500
Type Hosting 350 3500
Type Surfing 175 2200
you can do the following:
create a group based on type
use the group header band for labels (instead of column header band).

Crystalreport display only once for duplicated record

In my crystal report, records are showing like that.
NAME DEPOSIT REMARK
LUKE 100.00 DECEMBER
LUKE 10.00 NOV
LUKE 10.00 NOV
But we have found duplicated record in there. In this case, I don't want to touch my query and want to change only in crystal report. What I want to be is like
NAME DEPOSIT REMARK
LUKE 100.00 DECEMBER
LUKE 10.00 NOV
Any resolution will be appreciated.
If you are looking to achieve this in the Crystal Reports designer, then there is an option "Database" in the menu that says "Select Distinct Records". Try using this it will return you only unique records, but be sure you use the unique field as well in the Details section.
Hope this helps.

Summarizing each subgroup in Group Footer - Crystal Reports

I'm trying to work on a report for a client. Basically I need something like such
Group 1: Customer ID
Group 2: Truck ID
CustID Vehicle ID Detention Time
------ ---------- --------------
ABX 100 60
35
20
TOTAL: 115
200 80
15
TOTAL: 95
300 10
TOTAL: 10
TOTALS FOR CUSTOMER ABX
100 115
200 95
300 10
Is there anyway to accomplish this without a subreport? I was hoping for a "summary field" that I could summarize more than just a single value.
Thanks!
(FYI using Crystal Reports 2008)
Use a crosstab; place it in the report-footer section.
There might be a better way to do this, but the one that comes to mind is to use two arrays: One to store the truck ID and another to store the corresponding total. In each inner grouping (TruckID), just tack on another array element and store its total time. To display, you could cast the values to strings, attach a newline character after each entry, and set the field to "Can Grow". So altogether, you'd need three formulas: one to initialize the arrays (in GH1), one to update the arrays with sum({truck.time},{truck.ID}) (in GF2), and one to display each entry (in GF1).
With that being said, CR has terrible support for containers... You're limited to 1-dimensional, non-dynamic arrays that are gimped at 1000 items max. It doesn't sound like these would be big problems for what you're trying to do, but you will need to redim preserve the arrays unless you know ahead of time how many trucks you'll have per customer.

Crystal Reports XI Cross tab summarised field how to stop cell rows of the same value merging?

I have created a cross tab however if I have a firstname field it merges the rows together if there are two names which are the same. How do you get it to display the names in the each row. In the example below Sarah is not displayed twice as the cells are merged together.
Firstname Lastname
Judy Collins
Sarah Dane
Smith
Joe Dine
Mary Lane
It sounds like you grouped your crosstab on the first name only. I would recommend:
Make a new Formula (Call it "FullName")
In the formula, combine the first name and last name, e.g. something like {First Name}&{Last Name}
Edit your crosstab to group by the FullName formula instead.
Does this help?
EDIT
Based on your comment, I don't think your comment is with Crystal. You need a "unique ID" of some sort, a distinct number for each person. My original suggestion was trying to use the user's full name as a unique ID, but that won't work if your dataset is big enough to include multiple people with the same name. Does your dataset have any kind of unique ID? What is this crosstab trying to display? There might be a better way.