Jump to content

print when expression: max line


birgit

Recommended Posts

Hi,

can anybody help me how to set up a "print when-expression" to print the last (max) detail entry.

I have a detail band which gets up to 4 lines of data (maybe less if data not available).

I need to highlight the last data-line with a print when expression. So I set a "print-when-expression" on a coloured rectangle. Unfortunately I just get it to work with exactly four data-lines with following expression:

new Boolean( $V{ANR_GROUP_COUNT}.intValue() % 4 ==0 )

How do I modify this expression to give a boolean-true not on a static 4th data-line but on my last printed data-line (so, if I just have two lines of data on the second? I tried with highest and max for group_count but don't get it to work.

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

i think it's better to work with the computing power of DB (when it's possible) rather than use report logic...

so you can use the DB rownum of each record to catch when you have the last record...

try this (oracle version)

select aTable.*,
       case
           when rownum=(select max(rownum) from myTable [where conditions] ) then 1
           else 0
       end as is_last_record
from myTable aTable
[where conditions]
order by something

in this way you have a column that has 1 only on the last record.

NOTE that the [where conditions] MUST be the same in the query to make it running properly.

using this column you can catch the 1 (or another if you prefer) value in the report and then, using the report logic, you can print or not something.


so, your "print when" condition is
new Boolean($F{IS_LAST_RECORD}.intValue()==1)

 

(if it works... karma points please :) )

 

 




Post Edited by slow at 03/17/2010 14:36
Link to comment
Share on other sites

  • 3 weeks later...

thanks mdahlmann, that was a good tip and worked for me.

the solution of slow is interesting either, but did not work for me because I just get the four newest records from the whole data and not each newest fourth record of each anr (key is jear, month, anr and  I needed to get anr data of newest year month). A played around with it using group by etc., but did not get it to work correctly. however the max(rownum) expression was interesting for me.

Link to comment
Share on other sites

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