How to Sum values of column corresponding to one column in jasper - jasper-reports

In jasper i have one requirement like, sum all the data of the column based on another column. I know how to show sum of all the data in the column. But please suggest me for this requirement.
Emp-Category Emp-Id Salary
---------------------------------------
Cate - A 1 128
2 50
3 89
total 267
Cate - B 4 123
5 50
6 100
total 273
Total Expenses 540
So there will be many number of categories, which will be getting from database.
Please suggest me how to do this approach.

In that case, you can use groups...
You can refer to the link below for tutorial :)
http://www.tutorialspoint.com/jasper_reports/jasper_report_groups.htm

Related

Tableau display 3 measures in 1 column

I am building a report in Tableau with 4 fields. 3 of these fields are measure fields. This is what it looks like.
Name Sum Profit Loss
Emmy 15 10 5
Sara 23 18 2
Dave 10 1 2
But, I want it to look like this. I want a new column called metrics that pulls in those 3 values.
Metrics
Emily 15
10
5
Sara 23
18
2
Dave 10
1
2
May I have some guidance on how I can approach this?
The easiest way to solve this is by bringing "Measure Names" to Rows
You can hide the header names of the measures as well. hope that helps

How to determine the number of digits of a number in a table

I am trying to determine the number of digits of a number in a table. For example if I have a table like this:
4 200 50 1236
69 54 285 1
1458 2 69 555
The answer would be
1 3 2 4
2 2 3 1
4 1 2 3
I used to be able to do this with this code
strlength(num2str(ADCPCRUM2(i,2)))
but then my input was numeric, and not a table.
How do I determine the length of a number in a table?
floor(log10(A)) does this. log10() basically counts the number of digits before/behind the decimal separator where the most significant number is.
When using this on a table, a simple call to table2array() should solve it.
Caveat: this only works for integers; for non-integer inputs it would get a lot more involved.

Spotfire data table merge using nearest neighbour values

I am trying to merge two data tables (tables A and B) in Spotfire 7.10 using insert columns to give the resultant table C. My problem is i cannot get the join i need on Depth because Depth in tables A and B are not exact matches. What i need is to match Table B to Table A based on a match using Depth to its nearest value i.e Depth 10.5 (table B) matches Depth 10 (Table A). Is this possible in Spotfire or using an TERR R script?
Table A
Depth data
10 2
20 4
30 3
40 5
50 7
Table B
Depth data 2
10.5 100
30.5 112
50.5 125
Table C
Depth data data 2
10 2 100
20 4
30 3 112
40 5
50 7 125
many thanks for any help
It depends on the range of values you may have in both tables for Depth, but you may find that simply rounding the result to the nearest 10 in Table B will suffice. Then you can join based on this.
Round([Depth]/10,0)*10

select every 3rd participate from a list and make and average in matlab

I got 3 lists with grades ranging from 0-100 represting 3 different tests.
each list has an equal number of indxes (represting participates).
For example- the 1st indexes in the lists- list1,list2 and list3, are the grades of the first particiapte in the 3 different tests.
I need to make a new group (named group1) that select evey 3rd participate, starting from the first, and than calculate the avarage of this group scores.
i'll appriciate any help!!
Hopefully instead of three 'lists' you are actually using a 3 column matrix for this? e.g.
testScores = [20 48 13;
85 90 93;
54 50 56;
76 80 45
...]
From here it is trivial to select every third participant:
testScores(1:3:end, :)
and then to find the mean:
mean(testScores(1:3:end,:),2)

crystal crosstab need to limit columns # of columns

I am using a Crystal crosstab. My rows are lab results and my columns are dates. I am sorting the dates in descending order so that the most current dates are listed first. I know I can use the TopN formula for rows to limit to a certain number of rows but I need to limit it to a certain number of columns preferably 10. In the example below I would not want to show anything after 10/10/11.
10/1/12 9/3/12 7/16/12 5/8/12 4/22/12 3/17/12 1/9/12 12/3/11 11/15/11 10/10/11 9/23/11 8/18/11 7/7/11 6/8/11
Calcium 8.5 9 9.1 9 8.9 8.9 9 9 9 9 9 9 8.9 9
Vitamin D 45 45 51 49 56 50 51 55 60 66 60 59 60 61
Any guidance would be greatly appreciated.
Thanks
Jill
I think the cross tab can only limit columns if the names are specified which will not be possible with dates.
There are two possible work arounds I can think of:
1 - limit via the query:
Go to Report > Select Expert > Record and select the date field, click formula then add this formula (for 10/10/2011):
{Mytable.DateField} < Date (2011, 10, 10)
or for a dynamic date (older than 1 year):
{Mytable.DateField} < DateAdd ("yyyy", -1, CurrentDate)
2 - The other option is to create cross-tab as a standard report, this means the dates will be vertical rather than horizontal.
You can add a group to the report by date then add values for each type as summaries, let me know if you prefer this and I can explain in more detail.