Jump to content
We've recently updated our Privacy Statement, available here ×

Convert Month name from month number


nehachd38

Recommended Posts

Hi, I am new to Jasper and creating X-Y chart . On x-axis I want to dispay month name but currently numbers 4.0, 4.5 , 5.0 like this are coming.

I am using below sql query :

select `description - output`.Keywords,
month(details.Date),
count(distinct `description - output`.`Incident ID`)
from
idg_dataquality_db.`description - output`,
idg_dataquality_db.details
where
`description - output`.`Incident ID` = details.`Incident ID`
group by `description - output`.Keywords, month(details.Date)

If I use monthname in query the Jasper studio is giving error : java.lang.String cannot be cast to java.lang.Number

 

Below is my whole source code: <?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.3.0.final using JasperReports Library version 6.3.0  -->
<!-- 2018-09-26T12:55:12 -->
<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="Keyword trend over a period of Time" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="108161ea-b60a-409a-b1fd-615f83762f54">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="DQ Dashboards"/>
    <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
    <queryString>
        <![CDATA[select `description - output`.Keywords,
month(details.Date),
count(distinct `description - output`.`Incident ID`)
from
idg_dataquality_db.`description - output`,
idg_dataquality_db.details
where
`description - output`.`Incident ID` = details.`Incident ID`
group by `description - output`.Keywords, month(details.Date)]]>
    </queryString>
    <field name="Keywords" class="java.lang.String"/>
    <field name="month(details.Date)" class="java.lang.Integer"/>
    <field name="count(distinct `description - output`.`Incident ID`)" class="java.lang.Long"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="46" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="0" width="560" height="30" uuid="a7a3a2f6-309f-48e4-bcb7-a797e01a9e78"/>
                <textElement textAlignment="Center">
                    <font size="18" isBold="true"/>
                </textElement>
                <text><![CDATA[Keyword Trend over a period of Time]]></text>
            </staticText>
        </band>
    </title>
    <summary>
        <band height="250" splitType="Stretch">
            <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
            <xyLineChart>
                <chart evaluationTime="Report">
                    <reportElement x="0" y="0" width="560" height="250" uuid="42d9a7f3-ede2-4eaf-b4fd-4544070f526c"/>
                    <chartTitle/>
                    <chartSubtitle/>
                    <chartLegend/>
                </chart>
                <xyDataset>
                    <xySeries autoSort="true">
                        <seriesExpression><![CDATA[$F{Keywords}]]></seriesExpression>
                        <xValueExpression><![CDATA[$F{month(details.Date)}]]></xValueExpression>
                        <yValueExpression><![CDATA[$F{count(distinct `description - output`.`Incident ID`)}]]></yValueExpression>
                    </xySeries>
                </xyDataset>
                <linePlot>
                    <plot/>
                    <categoryAxisFormat>
                        <axisFormat/>
                    </categoryAxisFormat>
                    <valueAxisFormat>
                        <axisFormat/>
                    </valueAxisFormat>
                </linePlot>
            </xyLineChart>
        </band>
    </summary>
</jasperReport>

 

Please help me to write a expression to type cast and dislay month name instead of numbers. 

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...