Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

presenting all records that meet a condition plus the first record only that does not meet the cond

Status
Not open for further replies.

dovl

Programmer
Jun 28, 2019
1
IL
Hi

I have a report that compare running total with a constant.
I want to present all records where running total is smaller then constant plus (and only) the first record where running total is equal or greater then constant.
tried the following :1. identify first record that meet the condition
WhilePrintingRecords;
numberVar N := 0;
if ({@accum_stoc}>=0 and next({@accum_stoc} )>=0 and Previous ({@accum_stoc} )<0 ) then N:={VU_QNTY_RUNNING_TTALS.DOC_NBR};
N;
then suppress records where recordNumber<= N+1;

However i am getting only n record # 141 in the example
and it does not work when part changes.



record
Number Rtotal const @accum_stoc part
140 24545 26650 2105 XXX
141 24571 26650 2079 XXX
142 29571 26650 -2921 XXX
143 450 2135 YYY

thanks
 
Your post is confusing since you say you want to show all records up to and including the first one where the constant minus the accumulated stock is less than (<) 0, but then you show a formula that would suppress records that are less than N+1. I'm assuming you really meant to suppress records greater than (>) N+1.

I'm also unclear on whether you want to show records for parts where the accumulated stock does not exceed the constant. Please clarify.

Anyway, try this:

First you should have a group on part, even if you don't want to show the group header/footer, so that you can add a reset formula to the group footer. Create three formulas:

//{@threshold record} to be placed the in the detail section:
whileprintingrecords;
numbervar cnt;
numbervar amt;
numbervar prev := amt;
amt := amt + {table.stockamount});
if {table.constant}-amt <=0 then
cnt := cnt + 1;

//{@diff} for display in detail section:
evaluateafter ({@threshold record});
numbervar amt;
{table.constant}-amt;

//{@totalstock} for display of accumulated stock in detail section:
whileprintingrecords;
numbervar amt;

//{@reset} to be placed in part group footer:
whileprintingrecords;
numbervar amt := 0;
numbervar cnt := 0;

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top