• Status: Solved
• Priority: Medium
• Security: Public
• Views: 290
• Last Modified:

# crystal formula - date range 1,2,3 months

Hi,
How can I create formula like this ? What function should I use ?
Example:
if {date.field} in last0to30days then {qnty} * {price}  else 0
I need formula for:
0to30 days back from currentdate
31to60days back from currentdate
61to90days back from currentdate
Maybe I should use something with month({date.filed)=....
please advise
henry
0
henryk123
Asked:
• 5
• 3
1 Solution

Commented:
if {date.field} in Aged0to30days then
{table.qnty} * {Table.price}
else
0
0

Commented:
Sorry - posted too early...
For your 30 days formula use...

if {table.datefield} in Aged0to30days then
{table.qnty} * {Table.price}
else
0

Then create similar formulas using
Aged31to60days
Aged61to90days
0

Author Commented:
thx working good
Can I ask something more ?
0

Commented:
As long as it is related to this Q, then Yes.
Otherwise post a new Q.
0

Author Commented:
ok ,
I have subreport in my main report.
I'd like show in main report's footer sums from subreport's report footer. How to do that ?
0

Commented:
You have to declare a shared variable in the main report
(formula field in the report header - example:
shared numbervar mytot:=0;
""

In the subreport footer, create a formula field, declare the same variable and assign it the value you want it to have.

In the main report footer, create a formula field and declare the shared variable again and also specify it as the output .
0

Author Commented:
In my subreport i have formula field in report header {@sum shipments}
inside: sum ({@ship0to30}) + sum({@ship31to60}) + sum ({@ship61to90})
I need this field use in main report:

I prepared something like that:

In main report header:
WhilePrintingRecords;
Shared NumberVar SubValue1;

In subreport - report footer:
WhilePrintingRecords;
Shared NumberVar SubValue1;
SubValue1:={@ship0to30};

In mainreport after subreport:
WhilePrintingRecords;
Shared NumberVar SubValue1;
SubValue1

Finish formula:
I'd like show diffrenece between sums (sum from main report and sum from subreport)
My formula:
WhilePrintingRecords;
Shared NumberVar Subvalue1;
{@sum backlog}- subvalue1

Unfortunately, doesn't work.
Shows me numbers but completely incorrect.
Did I any mistakes in formulas or this share values don't work good with sums ?
h

0

Commented:
All looks as it should to me.
Can you temporarily show the result of this formula as below and see if looks OK...

In subreport - report footer:
WhilePrintingRecords;
Shared NumberVar SubValue1;
SubValue1:={@ship0to30};
subvalue1
0

## Featured Post

• 5
• 3
Tackle projects and never again get stuck behind a technical roadblock.