Print GroupWise Sum details in another Group Jasper Report - jasper-reports

I am using jasper studio and I want to print Group wise sum in another group footer for better understanding take a look below.
Class Group Header: Class One
Student Group Header: Student One
Subject | Total Marks | Obtained Marks
ABC | 100 | 50
PQR | 100 | 80
AER | 100 | 30
Student Group Footer: Student One Total Obtained Marks : 160
Student Group Header: Student Two
Subject | Total Marks | Obtained Marks
ABC | 100 | 20
PQR | 100 | 10
AER | 100 | 30
Student Group Footer: Student Two Total Obtained Marks : 60
Here above i can print each student's obtained marks separately in student group footer, but i want to print same in Class group footer which means i want output like below
Class Group Header: Class One
Student Group Header: Student One
Subject | Total Marks | Obtained Marks
ABC | 100 | 50
PQR | 100 | 80
AER | 100 | 30
Student Group Header: Student Two
Subject | Total Marks | Obtained Marks
ABC | 100 | 20
PQR | 100 | 10
AER | 100 | 30
Class Group Footer:
Student One Total Obtained Marks : 160
Student Two Total Obtained Marks : 60
How can i achieve this result? Thank you in advance :)

In Class group footer (or summary band) , drag and drop 'Crosstab' from pallete.
Select Create a crosstab from existing database
select column group = class
select row group = Student
select Measures = Marks / calculation=sum
You can watch tutorials on how to use Crosstab in jasper studio

Related

Count records between rolling date range in Tableau

I have a file with a [start] and [end] date in Tableau and would like to create a calculated field that counts number of rows on a rolling basis that occur between [start] and [end] for each [person]. This data is like so:
| Start | End | Person
|1/1/2019 |1/7/2019 | A
|1/3/2019 |1/9/2019 | A
|1/8/2019 |1/15/2019| A
|1/1/2019 |1/7/2019 | B
I'd like to create a calculated field [count] with results like so:
| Start | End | Person | Count
|1/1/2019 |1/7/2019 | A | 1
|1/3/2019 |1/9/2019 | A | 2
|1/8/2019 |1/15/2019| A | 2
|1/1/2019 |1/7/2019 | B | 1
EDITED: A good analogy for what [count] represents is: "how many videos does each person rented at the same time as of that moment?" With the 1st row for person A, count is 1, with 1 item rented. As of row 2, person A has 2 items rented. But for the 3rd row [count]= 2 since the video rented in the first row is no longer rented.

PostgreSQL get aggregated results based on two tables

I have two tables,
1. items
2. festival_rents
Sample records:
items
id | name | rent
------------------------
1 | Car | 100
2 | Truck | 150
3 | Van | 200
Sample records:
festival_rents
id | items_id | start_date | end_date | rent
------------------------------------------------
1 | 1 | 2018-07-01 | 2018-07-02 | 200
2 | 1 | 2018-07-04 | 2018-07-06 | 300
3 | 3 | 2018-07-06 | 2018-07-07 | 400
The table items contains list of items with name and rent. Each item in the items table may or may not have festival_rents. The table festival_rents has higher rents for each item for a date range with start_date and end_date. It is possible for a item to have multiple festival_rents with different date ranges. But it's for sure that date ranges for multiple festival_rents belonging to a same item won't collide and all date ranges are isolated.
The query that I'm looking for is, for a given start_date and end_date range, for each item in the items table, calculate the total rent and display each item with it's calculated total rent. The rent calculation for each item should include the festival_rents also, if any of the items has festival_rents falling within the given start_date and end_date.
Expected result:
Input: start_date=2018-07-01 and end_date=2018-07-06
Output:
id | name | total_price
------------------------
1 | Car | 1100 // 1st 2 days festival rent + 1 day normal rent + last 3 days festival rent (2 * 200) + (1 * 100) + (3 * 200)
2 | Truck | 900 // 6 days normal rent (6 * 150)
3 | Van | 1400 // 5 days normal rent + 1 day festival rent (200 * 5) + (400 * 1)
You need a list of days either on a table or create on the fly:
How to get list of dates between two dates in mysql select query
Generating time series between two dates in PostgreSQL
SELECT i.name, SUM (f.rent)
FROM allDays a
JOIN festival_rents f
ON a.day >= f.start_date
AND a.day < f.end_date
JOIN items i
ON f.item_id = i.item_id
WHERE a.day BETWEEN #start_date
AND #end_date
GROUP BY i.name
I assume the end_date is open range. So if you have ranges [A,B) and [B,C) Date B will have the rent from [B,C)

Drools: create a conditional rule to match an input as list for each condition with permutations and combinations

In Drools how do I create a conditional rule to match if
1) input is a list.
2) each condition column will has its own list
3) Condition should match in permutations and combinations of all condition lists
If my decision table is in below format
------------------------------------------------
COND. | CONDITION | CONDITION| ACTION
------------------------------------------------
Store | ProjectCode | Country | ArticleNumber
------------------------------------------------
10 | 1001 | USA | AD112
20 | 1002 | UK | AD113
30 | 1003 | USA | AD114
40 | 1004 | SWE | AD112
50 | 1005 | GER | AD114
I will have conditions in list form like below
ArticleRule{
List<String> stores = Arrays.asList("10","30","40","50");
List<String> projectCodes = Arrays.asList("1001","1002","1004","1005");
List<String> countries = Arrays.asList("USA","GER","UK");
}
My result by creating a permutation and combination of all list would be.
Output : (AD112,AD114)
In my real use case each list might have 1000 values in it.
And my decision table can have a million records.
How can I achieve using drools.
You should have each row as a fact Article with fields store, projectCode, country, articleNumber. Your rule would be
rule select
when
$article: Article(
store in ("10","30","40","50"),
projectCode in ("1001","1002","1004","1005"),
country in ("USA","GER","UK") )
then
System.out.println( $article.getArticleNumber );
end

Crystal Reports - Select distinct records in group

I'm trying to figure out how to show distinct records in groups in crystal reports. The view I wrote returns something like this:
Field 1 | Field 2 | Field 3
----------------------------------
10 | 111 | Record Info 1
10 | 111 | Record Info 1
10 | 222 | Record Info 2
20 | 111 | Record Info 1
20 | 222 | Record Info 2
The report groups are based off field one, and I want distinct fields 2 and 3 for each group:
Field 1 | Field 2 | Field 3
----------------------------------
10 | 111 | Record Info 1
10 | 222 | Record Info 2
20 | 111 | Record Info 1
20 | 222 | Record Info 2
Field 2 and 3 are always the same, Field 1 acts as an FK reference to any entries in the view. Selecting distinct xxx in the view isn't really viable due to the huge amount of columns being brought in.
Can this be done in CR?
Cheers
Create a group for field1, field2
Hide Details area, field1 group area header and field1 group footer
Drop all the columns you want to show in the field2 group area header/footer.
Good luck!
You might also consider using Database | Select Distinct Records.

Crystal Report Crosstab Calculations

In my crosstab, I am trying to add a summarized field that will take two other summarized fields and create a percentage based off of those.
One field totals all of the appointments for a provider (count of appt), while the other one totals the number of possible sales opportunities (sum of opp). What I am trying to add is a summarized field that is esentially opp/appt in percentage form.
How would I go about doing this?
Week 1 | Week 2 | Week 3 | Week 4|
Provider A | | | |
Appts 3 | 3 | 4 | 1 |
Opps 1 | 2 | 1 | 1 |
Opps/Appts ?? | ?? | ?? | ?? |
In Crystal Reports 2008:
Select 'Opps' calculation field; choose Embedded Summary, then Insert Embedded Summary
Select newly-created embedded-summary field; right click; choose Embedded Summary, then Edit Calculation Formula
Add the following text:
Local Numbervar Denominator:=GridValueAt (CurrentRowIndex, CurrentColumnIndex, 0);
Local Numbervar Numerator:=GridValueAt (CurrentRowIndex, CurrentColumnIndex, 1);
If Denominator<>0 Then Numerator/Denominator * 100;