How to create report in the format Like this? - jasper-reports

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).

Related

how to suppress group header 1 if group header 2 is not showing anything

please help this noob on suppressing a group header 1 if group footer 2 is not displaying anything might be because there are no records to display, or all records are suppressed. I have a suppressed condition on group footer 2
IACode Group header #1 [Description]
ICode Group header #2
Details | itemcode | date | aantal | qty (supressed)
ICode Group footer #2| itemcode | date | (SUM)aantal | SUM(qty)
IACode Group footer *1
sample result
ABC Company (no data)
Helios Corporation
xx1001 09/10/2022 200 100
xy2091 09/22/2022 125 099
Super Tech Company
yy2222 01/10/2021 100 234 (suppressed as per suppress condition)
it should only show
Helios Corporation
xx1001 09/10/2022 200 100
xy2091 09/22/2022 125 099
current suppression condition # x+2 of Group Footer #2
ISNULL({qty}) OR {#datum} > 90 OR {aantal} = 0 (this is the only formula for the suppression).
and for the formula datum is date('9/1/2022') - {table.date}.
You have to evaluate the fields within Group Header 2 while printing Group Header 1.
So imagine a Crystal Report for inventory items. If I group my inventory items first on ITEMNO, and then on REVISION, I will have a report with ITEMNO in Group Header 1, and REVISION in Group Header 2. Then the details sections can contain other fields such as ONHAND_QTY, PRICE, STD_COST, ect...
Not every item will have a REVISION, so there will be some NULL values in this field. If I wanted to suppress Group Header 1 when Group Header 2 contains no data, its easily done when the fields within Group Header 2 all contain NULL values. To do this I simply use the following formula in the Suppress property of the Group Header 1 section.
ISNULL(GroupName ({ARINVT.REVISION}))
If the REVISION field is NULL, this formula returns TRUE and suppresses Group Header 1. If you have multiple fields in Group Header 2, you will need to test each field for NULL values. Now the formula becomes:
ISNULL(GroupName ({ARINVT.REVISION})) & ISNULL(OTHER_FIELD_1) & ISNULL(OTHER_FIELD_2)...
Now the tricky part comes into play when you need to suppress Group Header 1 because Group Header 2's fields have all been suppressed and do not contain NULL values. In order to satisfy this requirement, you will need to create an aggregate of all of the formulas that suppress the fields in Group Header 2. And then use that same logic to suppress Group Header 1. Its hard to provide much of an example of this without full knowledge of how you are suppressing fields within Group Header 2. I'm willing to give it a try though if you can share all of the formulas used to suppress the fields in Group Header 2.
Now you need to combine the formula for supressing Group Header 1 when all the fields in Group Header 2 are NULL with the aggregate of the formulas used to suppress fields within Group Header 2. This would roughly look like this:
ISNULL(GroupName ({ARINVT.REVISION})) or [aggregate formula goes here]
This formula should then return a value of TRUE if all of the fields are NULL or if all of the fields are suppressed within Group Header 2.

Crystal Reports SUM formula help. Don't SUM values with specific IDs

I have a table with rows of Invoice data and I want to SUM the values of all line items where the Item ID is not equal to 0000 or 9999.
The Item IDs I want to exlcude 0000 and 9999 never change.
ITEM ID
NAME
WORK VALUE
TOTAL COMPLETED
0000
HOLD 1
0.00
1,234
1234
MATERIAL A
333.00
76.00
1235
MATERIAL B
567.00
7043.00
1236
MATERIAL C
981.00
321.00
1237
MATERIAL 4
430.00
5445.00
1238
MATERIAL 5
10.00
897.00
1239
MATERIAL 6
18.00
654.00
1240
MATERIAL 7
882.00
3.00
1241
MATERIAL 8
777.00
65.00
9999
ZY HOLD
0.00
111.00
So the value returned in the report from the example above should = 18,502.00 not 20,847.00
I have tried:
IF NOT((TONUMBER({Invoices.InvoiceItems~ItemNumber}) = 9999))
THEN
(SUM({Invoices.InvoiceItems~InvoiceValue})+SUM({Invoices.InvoiceItems~TotalCompleted}
but this doesn't work, it still sums the value from the 9999 line item
I would create a Running Total Field to accomplish this.
A Running Total Field works very similar to the Summary Field, but allows a lot more control over which records are evaluated when summarizing the data. To setup a Running Total Field for your needs try the following steps.
Create a new Running Total Field.
Set the "Field to summarize" to use the Total Completed column from your database. Set the "Type of summary" to SUM.
Set the radio button in the "Evaluate" section to "Use a formula", then click the X-2 button to create the formula that will determine if a row of data should be included in the sum or not. Whatever formula you enter here will need to return a boolean value. When this value is TRUE, the row's data is included, and when it's FALSE the row's data will be excluded. I would use the following formula here: TONUMBER({Invoices.InvoiceItems~ItemNumber}) <> 9999 AND TONUMBER({Invoices.InvoiceItems~ItemNumber}) <> 0000
The last thing to do is the setup the Reset conditions for the Running Total Field. This would be used if you were grouping data in some fashion such as by Customer and would allow you to sum the data for a single customer, then reset to zero for the next customer. If you are not using any grouping you can probably just leave this set to "Never".
Click OK to finish. :)
At this point all you need to do is drop the Running Total Field you just created into your report. Be mindful about which sections you place this field within though. If you place it in a header section, you will likely find it doesn't add in the last record in your dataset because the report hasn't printed it to the details section yet. I recommend placing Running Total Fields in Footer sections to avoid this nuance.
I hope this helps! And if you do have some grouping levels that you need help with setting the reset conditions just let me know what the grouping levels are for your report and I can update this answer for you.
You can create a new formula similar to yours:
IF TONUMBER({Invoices.InvoiceItems~ItemNumber}) <> 9999
AND TONUMBER({Invoices.InvoiceItems~ItemNumber}) <> 0
THEN {Invoices.InvoiceItems~TOTALCOMPLETED}
ELSE 0
and then just sum this formula field up.

How to remove field and fit that section after remove field in crystal report

I created invoice bill using crystal report. Its looks something like this.
I need something like this. My client want to add Description below this amount. Description mean number. its coming from database like other fields. But that description is not every time print. Its mean sometimes that field is blank. I want to if that field is empty hide it and fit that section. I don't want to keep blank field every time. I want to if description is have I want to show is. if description is not i want to print only recordNo, item name, descountprice, quantity and amount without space.
Name | Price | Qty | Amount
-----------------------------
1 Phone 1500 X 2 3000
This is description
2 Mouse 1000 X 5 5000
No description. Blank field. I want to remove this
3 Fan 400 X 2 800
if no have any description I want to remove field and remove gap between 2 and 3
Place that field in its own section and, in Section Expert for that section, use the option to 'Suppress Blank Section' or use a dynamic expression for the Suppress property:

Change groups on new page

I need to create a summary page in crystal reports where it groups all the details with the same ItemName and calculates the totals
Data Example:
Balls 50
Balls 75
Food 10
Dolls 45
Food 68
On the last page in the report I need it to say
Balls 125
Food 78
Dolls 45
The report is already grouped by another detail, is there anyway to change what the report is grouped by on the last page?
Insert a cross-tab object in the report footer. Use the text field in your example as the 'row' field in the cross-tab. Use the numeric field in your example as the 'summarized' field. Leave the 'column' field blank.

SSRS custom code and page wise subtotal

i want to show per page wise sub total writing custom code.
the output would be like
Page 1
Employee Name Salary
------------- -------
keith 2000
Robin 4000
Mou 3000
Sub Total 9000
Page 2 i mean next page
Employee Name Salary
------------- -------
Markc 1000
Poll 2500
Sam 1500
Sub Total 5000
i want to declare a shared variable and a function and i need to call my function after each rows render and i will pass the the salary to that function and that function sum the salary and put the output in shared variable which i will display at the table footer. when i will go to next page then shared variable will be re initialize again and hold the sum of salary for that page. if i can do it then per page wise sub total can be shown. i am new in SSRS so i dont know how to associate my function call when each row render......please guide with code and full instruction in detail.
Here Where we Add the group name.
1) Show 3 records Per Page by adding a group named "subTotal" and writing following expression:
=Ceiling((RowNumber(Nothing)) / 3)
2) Add Sub Total Row in tablix
3) Write following expression: