Is using subreports the only solution here? - jasper-reports
We are using Jasper Reports to build our reports. There's a report which looks somewhat like this.
Rcpt No | Rcpt Date | Dealer Name | Items | Qty Ordered | Qty Received | Qty Accepted | Qty Rejected
====================================================================================================
1 | 12-08-14 | ABC Corp. |
| Item1 | 30 | 30 | 30 | 0
| Item2 | 30 | 30 | 30 | 0
| Item3 | 30 | 30 | 30 | 0
| Item4 | 30 | 30 | 30 | 0
----------------------------------------------------------------------------------------------------
1 | 12-08-14 | ABC Corp. |
| Item1 | 30 | 30 | 30 | 0
| Item2 | 30 | 30 | 30 | 0
| Item3 | 30 | 30 | 30 | 0
| Item4 | 30 | 30 | 30 | 0
----------------------------------------------------------------------------------------------------
1 | 12-08-14 | ABC Corp. |
| Item1 | 30 | 30 | 30 | 0
| Item2 | 30 | 30 | 30 | 0
| Item3 | 30 | 30 | 30 | 0
| Item4 | 30 | 30 | 30 | 0
----------------------------------------------------------------------------------------------------
We are using xml as the data source for the report. This is the XML:
<?xml version="1.0" encoding="UTF-8"?>
<data>
<period>
<fromDate>someFromDate</fromDate>
<toDate>someToDate greater than fromDate</toDate>
</period>
<receiptList>
<someStoresInwardReceiptNumber>
<_id>someMongoGivenId</_id>
<challanNo>someChallanNumber</challanNo>
<itemList>
<item>
<_id>someItemId</_id>
<description>someDescription</description>
<productCatlgNo>someProductCatalogNo</productCatlgNo>
<quantityInNumbers>
<acceptedQuantity>20</acceptedQuantity>
<declaredQuantity>20</declaredQuantity>
<receivedQuantity>20</receivedQuantity>
<rejectedQuantity>0</rejectedQuantity>
<units>pcs</units>
</quantityInNumbers>
<quantityinWeight>
<acceptedWeight>0</acceptedWeight>
<declaredWeight>0</declaredWeight>
<receivedWeight>0</receivedWeight>
<rejectedWeight>0</rejectedWeight>
<units null="true" />
</quantityinWeight>
</item>
<item>
<_id>someItemId1</_id>
<description>someDescription1</description>
<productCatlgNo>someProductCatalogNo1</productCatlgNo>
<quantityInNumbers>
<acceptedQuantity>0</acceptedQuantity>
<declaredQuantity>0</declaredQuantity>
<receivedQuantity>0</receivedQuantity>
<rejectedQuantity>0</rejectedQuantity>
<units null="true" />
</quantityInNumbers>
<quantityinWeight>
<acceptedWeight>300</acceptedWeight>
<declaredWeight>300</declaredWeight>
<receivedWeight>300</receivedWeight>
<rejectedWeight>300</rejectedWeight>
<units>kgs</units>
</quantityinWeight>
</item>
</itemList>
<partyName>somePartyName</partyName>
<receiptDate>someDate</receiptDate>
<receiptNumber>someStoresInwardReceiptNumber</receiptNumber>
</someStoresInwardReceiptNumber>
<someOtherStoresInwardReceiptNumber>
<_id>someMongoGivenId</_id>
<challanNo>someChallanNumber</challanNo>
<itemList>
<item>
<_id>someItemId</_id>
<description>someDescription</description>
<productCatlgNo>someProductCatalogNo</productCatlgNo>
<quantityInNumbers>
<acceptedQuantity>20</acceptedQuantity>
<declaredQuantity>20</declaredQuantity>
<receivedQuantity>20</receivedQuantity>
<rejectedQuantity>0</rejectedQuantity>
<units>pcs</units>
</quantityInNumbers>
<quantityinWeight>
<acceptedWeight>0</acceptedWeight>
<declaredWeight>0</declaredWeight>
<receivedWeight>0</receivedWeight>
<rejectedWeight>0</rejectedWeight>
<units null="true" />
</quantityinWeight>
</item>
<item>
<_id>someItemId1</_id>
<description>someDescription1</description>
<productCatlgNo>someProductCatalogNo1</productCatlgNo>
<quantityInNumbers>
<acceptedQuantity>0</acceptedQuantity>
<declaredQuantity>0</declaredQuantity>
<receivedQuantity>0</receivedQuantity>
<rejectedQuantity>0</rejectedQuantity>
<units null="true" />
</quantityInNumbers>
<quantityinWeight>
<acceptedWeight>300</acceptedWeight>
<declaredWeight>300</declaredWeight>
<receivedWeight>300</receivedWeight>
<rejectedWeight>300</rejectedWeight>
<units>kgs</units>
</quantityinWeight>
</item>
</itemList>
<partyName>somePartyName</partyName>
<receiptDate>someDate</receiptDate>
<receiptNumber>someOtherStoresInwardReceiptNumber</receiptNumber>
</someOtherStoresInwardReceiptNumber>
</receiptList>
</data>
Is using subreport the only way to create this report? Or is there a way which we are not aware of?
Thanks in Advance.
We can "group by" these results either by Rcpt Date or by Dealer Name.
Thanks
Related
postgreSQL question: get data by last date of each record and subtract from last date number of days
Please help me make a request. i'm at a dead end. There are 2 tables: “Trains”: +----+---------+ | id | numbers | +----+---------+ | 1 | 101 | | 2 | 102 | | 3 | 103 | | 4 | 104 | | 5 | 105 | +----+---------+ “Passages”: +----+--------------+-------+---------------------+ | id | train_number | speed | date_time | +----+--------------+-------+---------------------+ | 1 | 101 | 26 | 2021-11-10 16:26:30 | | 2 | 101 | 28 | 2021-11-12 16:26:30 | | 3 | 102 | 24 | 2021-11-14 16:26:30 | | 4 | 103 | 27 | 2021-11-15 16:26:30 | | 5 | 101 | 29 | 2021-11-16 16:26:30 | +----+--------------+-------+---------------------+ The goal is to go through the train numbers from the Trains table, take from the existing ones from the Passages table by the latest date (date_time) and the number of passages for “the last date for each train” - N days. as I understand date_time - interval "N days". should get something like: +----+--------+---------------------+----------------+ | id | train | last_passage | count_passages | +----+--------+---------------------+----------------+ | 1 | 101 | 2021-11-10 16:26:30 | 2 | | 2 | 102 | 2021-11-14 16:26:30 | 1 | | 3 | 103 | 2021-11-15 16:26:30 | 1 | | 4 | 104 | null | 0 | | 5 | 105 | null | 0 | +----+--------+---------------------+----------------+ ps: "count_passages" - for example, last passage date minus 4 days I tried through "where in" but I can’t create the necessary and correct request
Check previous and next record
I'm trying to compare different costs from different periods. But I dont no how I can compare the single record with the record before and after. What I need is a yes or no in my dataset when the costs from a records is the same as record before and record after. My dataset looks like this: +--------+-----------+----------+------------+-------+-----------+ | Client | Provision | CAK Year | CAK Period | Costs | Serial Nr | +--------+-----------+----------+------------+-------+-----------+ | 1 | 210 | 2017 | 13 | 150 | 1 | +--------+-----------+----------+------------+-------+-----------+ | 1 | 210 | 2018 | 1 | 200 | 2 | +--------+-----------+----------+------------+-------+-----------+ | 1 | 210 | 2018 | 2 | 170 | 3 | +--------+-----------+----------+------------+-------+-----------+ | 1 | 210 | 2018 | 3 | 150 | 4 | +--------+-----------+----------+------------+-------+-----------+ | 1 | 210 | 2018 | 4 | 150 | 5 | +--------+-----------+----------+------------+-------+-----------+ | 1 | 210 | 2018 | 5 | 150 | 6 | +--------+-----------+----------+------------+-------+-----------+ | 1 | 689 | 2018 | 1 | 345 | 1 | +--------+-----------+----------+------------+-------+-----------+ | 1 | 689 | 2018 | 2 | 345 | 1 | +--------+-----------+----------+------------+-------+-----------+ | 1 | 689 | 2018 | 3 | 345 | 1 | +--------+-----------+----------+------------+-------+-----------+ What i've tried so far: CASE WHEN Provision = Provision AND Costs = LEAD(Costs, 1, 0) OVER(ORDER BY CAK Year, CAK Period) AND Costs = LAG(Costs, 1, 0) OVER(ORDER BY CAK Year, CAK Period) THEN 'Yes ELSE 'No' END My expected result: +--------+-----------+----------+------------+-------+-----------+--------+ | Client | Provision | CAK Year | CAK Period | Costs | Serial Nr | Result | +--------+-----------+----------+------------+-------+-----------+--------+ | 1 | 210 | 2017 | 13 | 150 | 1 | No +--------+-----------+----------+------------+-------+-----------+--------+ | 1 | 210 | 2018 | 1 | 200 | 2 | No +--------+-----------+----------+------------+-------+-----------+--------+ | 1 | 210 | 2018 | 2 | 170 | 3 | No +--------+-----------+----------+------------+-------+-----------+--------+ | 1 | 210 | 2018 | 3 | 150 | 4 | No +--------+-----------+----------+------------+-------+-----------+--------+ | 1 | 210 | 2018 | 4 | 150 | 5 | Yes +--------+-----------+----------+------------+-------+-----------+--------+ | 1 | 210 | 2018 | 5 | 150 | 6 | No +--------+-----------+----------+------------+-------+-----------+--------+ | 1 | 689 | 2018 | 1 | 345 | 1 | No +--------+-----------+----------+------------+-------+-----------+--------+ | 1 | 689 | 2018 | 2 | 345 | 1 | Yes +--------+-----------+----------+------------+-------+-----------+--------+ | 1 | 689 | 2018 | 3 | 345 | 1 | No +--------+-----------+----------+------------+-------+-----------+--------+ You guys can help me further because I don't get the expected result?
You need to add in partition by Provision otherwise your lag and lead ordering will run across all Provision values: declare #d table(Client int,Provision int,CAKYear int, CAKPeriod int, Costs int, SerialNr int); insert into #d values (1,210,2017,13,150,1) ,(1,210,2018,1,200,2) ,(1,210,2018,2,170,3) ,(1,210,2018,3,150,4) ,(1,210,2018,4,150,5) ,(1,210,2018,5,150,6) ,(1,689,2018,1,345,1) ,(1,689,2018,2,345,1) ,(1,689,2018,3,345,1); select * ,case when Provision = Provision and Costs = lead(Costs, 1, 0) over(partition by Provision order by CAKYear, CAKPeriod) and Costs = lag(Costs, 1, 0) over(partition by Provision order by CAKYear, CAKPeriod) then 'Yes' else 'No' end as Result from #d order by Provision ,CAKYear ,CAKPeriod; Output +--------+-----------+---------+-----------+-------+----------+--------+ | Client | Provision | CAKYear | CAKPeriod | Costs | SerialNr | Result | +--------+-----------+---------+-----------+-------+----------+--------+ | 1 | 210 | 2017 | 13 | 150 | 1 | No | | 1 | 210 | 2018 | 1 | 200 | 2 | No | | 1 | 210 | 2018 | 2 | 170 | 3 | No | | 1 | 210 | 2018 | 3 | 150 | 4 | No | | 1 | 210 | 2018 | 4 | 150 | 5 | Yes | | 1 | 210 | 2018 | 5 | 150 | 6 | No | | 1 | 689 | 2018 | 1 | 345 | 1 | No | | 1 | 689 | 2018 | 2 | 345 | 1 | Yes | | 1 | 689 | 2018 | 3 | 345 | 1 | No | +--------+-----------+---------+-----------+-------+----------+--------+
Date have no data and will show the date with Zero Data in Crystal Reports
I have an output like this on my Crystal Reports: Example: Date(as group)| Hours | Counts ---------------------------------- 01-Feb-2018 | 20 | 5 03-Feb-2018 | 25 | 3 04-Feb-2018 | 22 | 3 05-Feb-2018 | 21 | 2 07-Feb-2018 | 28 | 1 10-Feb-2018 | 23 | 1 If you can see, there are days that missing because no data/empty, but I want the missing days to be shown and have a value of zero: Date | Hours | Counts ---------------------------------- 01-Feb-2018 | 20 | 5 02-Feb-2018 | 0 | 0 03-Feb-2018 | 25 | 3 04-Feb-2018 | 22 | 3 05-Feb-2018 | 21 | 2 06-Feb-2018 | 0 | 0 07-Feb-2018 | 28 | 1 08-Feb-2018 | 0 | 0 09-Feb-2018 | 0 | 0 10-Feb-2018 | 23 | 1 Thank you in advanced.
Aggregate all previous rows for a specific time difference
I have a Spark DataFrame with the following entries: | order id | time | amt | | 1 | 2017-10-01 12:00 | 100 | | 2 | 2017-10-01 15:00 | 100 | | 3 | 2017-10-01 17:00 | 100 | | 4 | 2017-10-02 16:00 | 100 | | 5 | 2017-10-02 23:00 | 100 | I want to add a column amount_prev_24h that has, for each order id, the sum of amt for all orders in the last 24 hours. | order id | time | amt | amt_24h | 1 | 2017-10-01 12:00 | 100 | 0 | 2 | 2017-10-01 15:00 | 100 | 100 | 3 | 2017-10-01 17:00 | 100 | 200 | 4 | 2017-10-02 16:00 | 100 | 100 | 5 | 2017-10-02 23:00 | 100 | 100 How would I go about doing it?
This is a pyspark code and similar to scala API. df = df.withColumn('time_uts', unix_timestamp('time', format='yyyy-MM-dd HH:mm')) df = df.withColumn('amt_24h', sum('amt').over(Window.orderBy('time_uts').rangeBetween(-24 * 3600, -1))).fillna(0, subset='amt_24h') I hope this may help you.
how to ignore repeated value at sum time?
I am new in JasperReports, I have one report which have tabular data Table Heading is ID | Product | Amount | Discount ---------------------------------- 1 | ABC | 12000 | 10 1 | ABC | 12000 | 10 1 | ABC | 12000 | 10 2 | ABC | 5000 | 20 2 | ABC | 5000 | 20 2 | ABC | 5000 | 20 2 | ABC | 5000 | 20 3 | ABC | 13000 | 25 3 | ABC | 13000 | 25 i want to use built in functionality of JasperReports like "print repeated value is unchecked" its display is not show repeated but when i try to do sum of amount it will give the all amount sum but i want to get out put like 12000+5000+13000 only so how can i get the result? I WANT TO GET RESULT LIKE THIS ID | Product | Amount | Discount ---------------------------------- 1 | ABC | 12000 | 10 | ABC | | | ABC | | 2 | XYZ | 5000 | 20 | XYZ | | | XYZ | | | XYZ | | 3 | PQR | 13000 | 25 | PQR | | ---------------------------------- Total 30000 55 ----------------------------------