Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7083877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:13:57+00:00 2026-05-28T07:13:57+00:00

I have a column in my database, which is the ColorCode column (Field name

  • 0

I have a column in my database, which is the ColorCode column (Field name $F{COLORCODE} ) that has values like ‘B’ and ‘R’ and ‘G’, I want to count the amount of them respectively to their color.

So I have variables called countBlue, the variables expression is $F{COLORCODE}==’B’ and put it in the Column Footer but the report counted everything including the R and G in that column, did I do the comparison statement wrongly?

also I have set up my countBlue variable class to java.lang.Integer, calculation as Count and reset type as Report

p/s sorry for bad english

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:13:58+00:00Added an answer on May 28, 2026 at 7:13 am

    You can use this expression (Calculation: Count; Reset type: Report; Increment type: None):

    <variable name="countBlue" class="java.lang.Integer" calculation="Count">
        <variableExpression><![CDATA[$F{COLORCODE}.equals("B") ? "SomeNotNull" : null]]></variableExpression>
        <initialValueExpression><![CDATA[Integer.valueOf(0)]]></initialValueExpression>
    </variable>
    

    or this (Calculation: Nothing; Reset type: Report; Increment type: None):

    <variable name="countBlue" class="java.lang.Integer">
        <variableExpression><![CDATA[$F{COLORCODE}.equals("B") ? $V{countBlue} + 1 : $V{countBlue}]]></variableExpression>
        <initialValueExpression><![CDATA[0]]></initialValueExpression>
    </variable>
    

    You can read about variables here.

    The JasperReports Ultimate Guide says:

    Calculation Count

    A count variable includes in the count the non-null
    values returned after evaluating the variable’s main expression, with
    every iteration in the data source. Count variables must always be of
    a numeric type. However, they can have non-numeric expressions as
    their main expression since the engine does not care about the
    expression type, but only counts for the non-null values returned,
    regardless of their type
    .
    Only the variable’s initial value expression
    should be numeric and compatible with the variable’s type, since this
    value will be directly assigned to the count variable when
    initialized.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In sql server database, I have column name Image which has urls like http://www.xyz.com/1009/image1.jpg
I have a column 'name' in Database which has values as 'john,smith'. I'm passing
i have a large mysql database table in which one column contains values ranging
We have a Oracle 9i database and OrderDetails table which has a column to
I have a column in my database that is typed double and I want
I have a non-nullable database column which has a default value set. When inserting
I am using rdlc report, i have a column in database which i want
I have a database which has a table with an XML column. The XML
I have a column in the database which is Name its string with null
I have a database column which contains varchar data type. I would like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.