Jaspersoft BI Tools

Services: Reports,Visualizations, Dashboards,Stories, Analysis,Self Service BI, Data Warehouse, ETL
Tools : Jaspersoft Design Studio, JasperReport Server, Talend ETL (Other tools : Pentaho, Tableau)

Search this site

Thursday, 15 March 2018

Tip: group count variable calculation in jasper reports


Group count calculation can be done as follows in jasper reports.

Scenario : 
Report Design:
<GroupNumber>  <GroupBand>

2    IamGroupValue2

1) Create your group (lets say Group1 , give the field value by which you want to group by)
2) Observe variables - there it creates a variable called "Group1_Count"
3) Create a new variable of Integer type , let say : groupCount
4) Give below expression for the groupCount variable
      $V{Group1_COUNT} == 1 ? ($V{groupCount} + 1) : $V{groupCount}
5) Put Increment Type= [Group]Group1 and Reset Type =Report and Initial Value=1
6) Pull this variable onto the group header where you want to get it.
7) Run the report observe the group count in output.

Calculation Image: 

Reference : 

Sunday, 11 March 2018

Tip : Text only background color in jasper reports with style tag


To get the text only background with given color in jasper text elements, write below code.

"<style backcolor=\"yellow\">Hello .! My background color is yellow </style>"

Importantly , give MarkUp=Styled in the TextField properties

Click on image to get better view: 

Sample output:

Example JRXML:  (Studio 6.4 professional version)

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.4.0.final using JasperReports Library version 6.4.1  -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4_1" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="01d3505b-1aa3-468b-ae16-491d8c5ceb57">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<band splitType="Stretch"/>
<band height="79" splitType="Stretch">
<reportElement x="0" y="0" width="555" height="79" uuid="1a620294-fdcf-42f3-8fc3-66548fc72941"/>
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<textElement textAlignment="Center" verticalAlignment="Middle" markup="styled">
<font size="14"/>
<textFieldExpression><![CDATA["<style backcolor=\"yellow\">Hello .! My background color is yellow </style>"]]></textFieldExpression>
<band height="35" splitType="Stretch"/>
<band height="61" splitType="Stretch"/>
<band height="125" splitType="Stretch"/>
<band height="45" splitType="Stretch"/>
<band height="54" splitType="Stretch"/>
<band height="42" splitType="Stretch"/>