cancel
Showing results for 
Search instead for 
Did you mean: 

How to make amount zero based on Minimum date

former_member205840
Active Contributor
0 Kudos
111

Hi,

Below is my requirement, I need to find minimum date in type group where group name equal to 'aaa' then compare rest of Transaction group dates, if any date is less than this date then make amount zero.

Ex: in 101 transaction minimum date for type 'aaa' is 01/01/2010 and when compare this date with rest of dates 01/01/2009 is less than this date so, my amount should be zero.

Transaction

typedateamountrequired results

101

aaa01/01/201056785678
101aaa01/10/201154645464
101def05/08/201098769876
101dez01/01/200956560

101

dex05/01/201176587658
102aaa01/10/201167856785
102aaa01/01/200945670
102xdw

11/12/2008

32343234
102dfe10/12/201021232123
102xsd03/12/201145634563

I can do this through sub report, but due to huge volume of date this report is running for 10 hrs.and it is not acceptable.  Need to do this in single report.

Thanks in advance for any suggestions.

-Sastry

Accepted Solutions (1)

Accepted Solutions (1)

abhilash_kumar
Active Contributor
0 Kudos

Hi Sastry,

Just a clarification, isn't 01/01/2009 the minimum date for 'aaa'?

Or, do you want the date comparison to be based on the 'first occurrence of aaa'?

-Abhilash

former_member205840
Active Contributor
0 Kudos

Hi Abhilash,

To give more clarity, my first group is Transaction and second group is type.  In my second group need to find minimum date for value 'aaa' and compare with rest of my first group dates.  If any date is less than this date then amount should be zero.

Thanks,

Sastry

abhilash_kumar
Active Contributor
0 Kudos

Hi Sastry,

Here's what you need to do:

1) Create a formula with this code and place this on the Report Header:

shared datevar array dd := cdate(0,0,0);

'';

2) Create another formula and place this on the Details:

shared datevar array dd;

if dd[1] = cdate(0,0,0) then

(

if {Type} = 'aaa' then

(

    numbervar x := x + 1;

    redim preserve dd[x];

    dd[x] := date(Minimum({Date},{Type}));

);

);

'';

3) Create another formula and place this on the Details. This is the formula to display the amounts:

evaluateafter({@test2});

shared datevar array dd;

if {Type} = 'aaa' and {Date} < dd[1] then

0 else {Amount}

I hope I interpreted your question correctly.

-Abhilash

former_member205840
Active Contributor
0 Kudos

Hi Abhilash,

Sorry for giving wrong example, below is the correct example.

Transaction

typedateamountrequired results

101

aaa01/01/201056785678
101aaa01/10/201154645464
101def05/08/201098769876
101dez01/01/200956560

101

dex05/01/201176587658
102aaa01/10/201167856785
102aaa01/01/200945674567
102xdw

11/12/2008

32340
102dfe10/12/201021232123
102xsd03/12/201145634563

Transaction Group--- > Typegroup--> from this type group I need to pickup minimum date for type='aaa' and within Transaction group if any date is less than this date then amount should be zero.

Here 101 Transaction gruop--01/01/2010 is minimum date for type group and within same Transaction group 01/01/2009 is less than 01/01/2010 so, amount is zero.

Like wise second Transaction group 102

Thanks for understanding,

Sastry

abhilash_kumar
Active Contributor
0 Kudos

OK, that should be even easier then:

1) Create a formula (@Min) with this code:

If {type} = 'aaa' then {date}

2) Create another formula with this code for the Amounts:

If Minimum({@Min}, {Transaction Group}) > cdate(0,0,0) AND

{Date} < Minimum({@Min}, {Transaction Group})

then 0 else {Amount}

-Abhilash

Answers (0)