SSRS custom code and page wise subtotal - ssrs-2008

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:

Related

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.

Jasper Report with more than one page

I'm currently using the report to print out the information of all the employees using the same format.
For example, here is the employee table in my database.
EmployeeID NAME AGE
----------------------
1 Tom 28
2 John 30
3 Tony 32
I just want to print out the information of the employees using the same format whenever there is other employees in the table. (first employee in first page, second in the second page.....)
Is there any way like that?
You can use PageBreak for each row so you can have a page
To implement this solution:
add the table component to your report
open the DataSet associated with this report and add to it the Group
set Group expression to
(int)($V{REPORT_COUNT} - 1)
check 'Start on a new page' property
see the link for more detail
http://community.jaspersoft.com/wiki/ireport-how-introduce-page-break-after-pre-defined-number-rows-table-component

How to get individual group totals in report

I have a jasper report being made with iReport, which is basically a list of pages received the day prior. The report has total pages for the whole day and then individual totals for each group of page types.
The requirements state I need to display all the totals above the listed records and groups (ex. display in the title band). I created a variable for the total of all pages and that works but am having trouble getting each individual group total.
It should look like:
Total pages received: 50
Total GROUP_A: 20 Total GROUP_B: 30
When I try to use the variable set up for group totals, it only gives me the last used group, so it would say 30. I'm unsure how to create a variable to get the total for only a specific group.
I could include in my SQL result set the totals but was asked to do it within iReport.
If I understand the problem right you need to put a copy of the variable that you are using in the group and put it in your title band. the trick is on the object in the title band make sure you have set the evaluation time & evaluation group group or report depending on what you are truing to get a total of.

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

How to add a conditional grand total in Crystal Reports?

I have a group running total that needs to be sum up at the report footer. Since thats not possible with CR I had to end up having another running total that refreshes "Never". But now I need to calculate some percentages at the group level based on this Grand total. Unfortunately I cannot access the value for grand total (because its another running total).
Confused?? Ok reports should look like below..
Column 1 | Colunm 2
======== =========
| Group 200 (Running Total Refresh at Group level) | 20% (200%1000) |
| Group 500 (Running Total Refresh at Group level) | 50% (500%1000) |
| Group 300 (Running Total Refresh at Group level) | 30% (300%1000) |
Footer 1000 (Running Total Never Refreshed)
But column 2 doesn't give me the correct value. it gives me 100% always means 200%200 or 500%500 etc.
Any idea how to fix this??
Thanx Lee, using a running total formula worked, I added following formula to the report footer,
numbervar Samples;
if {product.sku}="card-sample" then
Samples := Samples + {#num_qty};
Samples;
Then I use this formula to calculate column 2
Try this
Add a formula field for group percentage and then paste below code in it.
Group total / sum(column)
place this formula at your group level.
I should think your report total wants to simply be a summary field not a running total. Then your column 2 value can be calculated using running total / sum(field);
Here is an example:
I have two columns age and salary.
When age > 18 i want to add the salary.
Initially I used a running total with a condition {age} > 18
That didn't work well so i deleted the running total, and created a formula: if {age} > 18 then {salary} else 0
I then created a summary on that formula field.
Make sense?