birgit Posted March 16, 2010 Share Posted March 16, 2010 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 More sharing options...
slow Posted March 17, 2010 Share Posted March 17, 2010 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_recordfrom myTable aTable[where conditions]order by somethingin 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 isnew 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 More sharing options...
mdahlman Posted March 18, 2010 Share Posted March 18, 2010 birgit,You need a second variable. Create a variable that finds the max ANR_GROUP_COUNT. Then make the test to see of MAX_ANR_GROUP_COUNT equals ANR_GROUP_COUNT.Regards,Matt Link to comment Share on other sites More sharing options...
birgit Posted April 3, 2010 Author Share Posted April 3, 2010 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now