cancel
Showing results for 
Search instead for 
Did you mean: 

Shared Variable in summary formula

Former Member
0 Kudos

Hi All,

I would appreciate any help I can get on this.

I have a subreport that retrieves a Foriegn Exchange rate for a specific date ( main report & sub-report are linked by date). I have no problem passing the value to the main report but when I use that value in a summarized formula field (@Princip Rem Term) I get the following error "A summary field has been specified on a non-recurring field Details: @Princip Rem Term"

Here are my formulas

Sub-report:

@FX rate

Shared numbervar FX;

FX := TONUMBER({ZFI_EXCHANGE_RATE.MRATE})

Main report:

@FX Rate

shared numbervar FX;

@PrincipalCAD

if {ZFI_TREASURY.VTBFHAPO-WZBETR} = "USD" then

{ZFI_TREASURY.VTBFHAPO-BZBETR} * {@FX Rate} else

{ZFI_TREASURY.VTBFHAPO-BZBETR}

@Principal Rem Term

{@PrincipalCAD}*({ZFI_TREASURY.VTBFHAZU-DELFZ}-{@AsofDate})

Is there a way to solve this problem? Can't I use the value I retrieved from the sub-report as a staic vlaue and summarize it??

Thanks for help...very much appreciated!!

Romeo

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

What you'll have to do is manually summarize the field in the formula field @Principal Rem Term using a global variable, then create another formula field that will return the global variable's value and place it where you need it on the report.

HTH,

Carl

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Marshall,

Thanks for the helpful information, and it works fine, but when I try to summarize the filed @PrinccipalCAD, I still get an error message "A summary has been specified on a non recurring field.Details:@Principal CAD"

It seems that we cannot summarize a formula field with a value passed from a shared variable. Is there a way of summarizing a shared variable, without having to do a manual running total?

Thanks again!!

Romeo

Former Member
0 Kudos

Carl,

Are you saying that there's no way to pass the value from a shared variable as a static value to another formula and use it in a summarized filed??

If that's the case, I have too many fields that uses the value from the sub-report, it would take too much time to manually summarize them all.

Romeo

Former Member
0 Kudos

Hi Romeo,

If you are trying to save off any summary data you will need add the WhilePrintingRecords evaluation time function at the beginning each formula to make sure that they are evaluated in pass 2. You need all the data and sums to have been processed first before you save them off. However, It looks like you may not need it because you are using a database field directly but I mention it just in case.

Sub-report @FX rate

 
WhilePrintingRecords; 
Shared numbervar FX; 

FX := TONUMBER({ZFI_EXCHANGE_RATE.MRATE}); 

Main report @FX Rate: - in order to use the shared variable, it must be declared and then used hence the FX by itself on line 3 otherwise the formula will have no result. I think this is where you ran into a problem because this formula as written in your post would have no result.

 
WhilePrintingRecords; 
shared numbervar FX; 
FX; 

@PrincipalCAD - this formula can also use the shared variable FX directly instead of referencing @FX Rate. I think this is what Carl was getting at in his post. Both ways should work though.

 
WhilePrintingRecords; 
Shared NumberVar FX; 

if {ZFI_TREASURY.VTBFHAPO-WZBETR} = "USD" then 
{ZFI_TREASURY.VTBFHAPO-BZBETR} * FX else 
{ZFI_TREASURY.VTBFHAPO-BZBETR} 

@Principal Rem Term

 
WhilePrintingRecords; 
{@PrincipalCAD}*({ZFI_TREASURY.VTBFHAZU-DELFZ}-{@AsofDate}) 

I am not 100% sure if you need the whileprintingrecords declaration but it should not hurt to use it.

I think you were on the right track except for the main report FX Rate formula.

Marshall

Edited by: Marshall Lin on Apr 13, 2010 10:03 PM

Former Member
0 Kudos

Hi Carl,

Thanks for the respone...I'm not sure I fully understand your solution. Can you give me an example with the formulas I have posted.

Thanks again!

Romeo