Jump to content

FilterExpression based on group variable


egon_olsen

Recommended Posts

Hello,

I want to filter rows such that I get only the first row from each new group. I tried using the automatic variable $V{<group_name>_COUNT} and a custom variable using the First calculation but both fail. Whatever I tried, the final report contained only one entry or was completely empty.

This is what I want to do:

The entries in my table each have a date stamp. I want to report on them but only one record for each 7 days. Thus, the first record would be from today,  the next from 7 days ago, etc.

To this purpose I have written a little class that has a static field which is initialised when reading the first row and provides a method that returns how many weeks lie between the first row and the current row.

I have now created a group based on the week the record is in. Accordingly, all records less than 7 days ago are in the first group, those older but with an age of less than two weeks are in 2nd group, etc.

Now I want to filter out all rows except the first entry in a group. But with no luck.

Here are some elements from my report def:

<group name="weekly">
        <groupExpression><![CDATA[new StaticDateHolder().getWeeksDeltaForRow($F{t})]]></groupExpression>
</group>

<variable name="fst" class="java.sql.Date" resetType="Group" resetGroup="weekly" calculation="First">
        <variableExpression><![CDATA[$F{t}]]></variableExpression>
</variable>
<filterExpression><![CDATA[($V{fst}.equals($F{t})) ? Boolean.TRUE : Boolean.FALSE]]></filterExpression>

 

I assume this problem is connected with the order of initialisation of variable values and groups but I quick look in the fill method could not solve the problem.

Any suggestions?

Kind regards



Post Edited by egon_olsen at 11/09/2009 15:03
Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

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...