Skip to Content
0
Former Member
Jul 15, 2010 at 12:54 AM

FOX - Inside FOREACH Loop

116 Views

Guys,

I am trying to fix a FOX code. Below is the issue -

There are 2 key figures - YearToDate(YTD) and LifeToDate(LTD).

The formula is

{Current FISCYRPRD, LTD} = {Last FISCYRPRD of Previous Year , LTD} + {Current FISCYRPRD, YTD}

- The Fiscal Year / Period is open and this function has to run for all the Fiscal Year / Period.

________________________________________________________

ISSUE:-

EXPECTED -

FISCYRPRD / YTD / LTD

2009012 / 100 / 100

2010001 / 0 / 100

2010002 / 10 / 110

ACTUAL OUTPUT -

FISCYRPRD / YTD / LTD

2009012 / 100 / 100

2010001 / 0 / 0

2010002 / 10 / 110

________________________________________________________

The code is simple -

FOREACH FISCYRPRD.

{Current FISCYRPRD, LTD} = {Last FISCYRPRD of Previous Year , LTD} + {Current FISCYRPRD, YTD}

ENDFOR.

When there is 0 for YTD the value does not get posted for LTD. This is because of the FOREACH loop. But I cannot force a condition in a DO loop because this function is to run for all FISCYRPRD.

Any help in this would be highly appreciated!

Thanks!