. Adding different row values in Birt Report
You are creating a BIRT report and getting the selection of data from SQL.
Total Status
-------- ---------
6 Cancelled
3 Disputed
6 In Process
4 On Hold
4 Resolved
303 Shipped
You need to add Cancelled, Disputed and Resolved together and then divide the result with the total shipped. All of this should be done with an Expression. So x/303 where x is the sum of the desired values.
It’s not difficult to implement the requirement in Birt. You should use computed columns in your data set.
Add aSUM
on the columnTotal
and a filter only matching the rows based on the columnStatus
you want to select. The expression should look like:
if (row["Status"] == "Cancelled" || row["Status"] == "Disputed"
|| row["Status"] == "Resolved")
true
else
false
create a second computed column only containing the “Total” value where the Status is Shipped.
if (row["Status"] == "Shipped")
row["Total"]
Then create a third computed column where you divide both computed values and you are done.
row["sum"] / row["shipped"]
Comparison of esProc implementation:
A | |
1 | =$select Total,Status from totalShipped |
2 | =A1.select(Status=="Shipped").sum(Total) |
3 | =A1.select(Status=="Cancelled"||Status=="Disputed"||Status=="Resolved").sum(Total) |
4 | =round(A3/A2,4) |
The script will be clear at a glance. Especially when the data and calculation logic are more complicated, the advantages of using a simple script are more obvious, making report development and maintenance more efficient. For detail esProc integration with BIRT, see How to Call an SPL Script in BIRT.
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProcSPL
SPL Learning Material 👉 https://c.scudata.com
SPL Source Code and Package 👉 https://github.com/SPLWare/esProc
Discord 👉 https://discord.gg/cFTcUNs7
Youtube 👉 https://www.youtube.com/@esProc_SPL