BananaFury asked on # Crystal Formula

Hi,

I am trying to make the following formula work. I guess, I am looking for a sub query. I have tried the following..

local numbervar CntInformedRes;

CntInformedRes :=

if date({Archive_tblEvents.TableDate}) = today

and {Archive_tblEvents.SubStatusGroup} = "Accepted - Informed Reserve"

then 1 else 0;

local numbervar SumInformedRes;

SumInformedRes :=

if date({Archive_tblEvents.TableDate}) = today

and {Archive_tblEvents.SubStatusGroup} = "Accepted - Informed Reserve"

then {Archive_tblEvents.OutstandingReserves} else 0;

Sum(SumInformedRes) / Sum(CntInformedRes)

This doesn't work, it wants a field. It doesn't accept the variables assigned.

And..

Sum(

if date({Archive_tblEvents.TableDate}) = today

and {Archive_tblEvents.SubStatusGroup} = "Accepted - Informed Reserve"

then 1 else 0

)

/

Sum(

if date({Archive_tblEvents.TableDate}) = today

and {Archive_tblEvents.SubStatusGroup} = "Accepted - Informed Reserve"

then {Archive_tblEvents.OutstandingReserves} else 0

)

but with this it wants fields.

I think it is fairly clear what I am trying to achieve, and I bet the answer is simple.

Thanks

I am trying to make the following formula work. I guess, I am looking for a sub query. I have tried the following..

local numbervar CntInformedRes;

CntInformedRes :=

if date({Archive_tblEvents.Ta

and {Archive_tblEvents.SubStat

then 1 else 0;

local numbervar SumInformedRes;

SumInformedRes :=

if date({Archive_tblEvents.Ta

and {Archive_tblEvents.SubStat

then {Archive_tblEvents.Outstan

Sum(SumInformedRes) / Sum(CntInformedRes)

This doesn't work, it wants a field. It doesn't accept the variables assigned.

And..

Sum(

if date({Archive_tblEvents.Ta

and {Archive_tblEvents.SubStat

then 1 else 0

)

/

Sum(

if date({Archive_tblEvents.Ta

and {Archive_tblEvents.SubStat

then {Archive_tblEvents.Outstan

)

but with this it wants fields.

I think it is fairly clear what I am trying to achieve, and I bet the answer is simple.

Thanks

Crystal Reports

BananaFury

That's a shame.. I was aware that this could be tackled with three separate formulas, but I was really hoping it could be handled in one. Is there no other way of dealing with such formula?

Log in or sign up to see answer

Become an EE member today7-DAY FREE TRIAL

Members can start a 7-Day Free trial then enjoy unlimited access to the platform

or

Learn why we charge membership fees

We get it - no one likes a content blocker. Take one extra minute and find out why we block content.

Not exactly the question you had in mind?

Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.

ask a questionBananaFury

Yes, I need all the records for other areas of the report. Usually I would either use a sub report for just the records required, but having subs on reports with large tables and multiple groups isn't great, or multiple formulas, which was your approach, but that means of course if a report needs 10 Average formulas I end up with 30 formula fields, which is painful to build and maintain.

Your help has saved me hundreds of hours of internet surfing.

fblack61

Get an unlimited membership to EE for less than $4 a week.

Unlimited question asking, solutions, articles and more.

BananaFury

Thanks people. That counted weighted averages in an interesting approach. I haven't tried it so far to be honest, I just built it the way I was comfortable, but I will definitely experiment with it

Formula 1 - CntInformedRes

Open in new window

Formula2 - SumInformedRes

Open in new window

Formula 3 - MySummary

Open in new window

The problem is summary formulas are evaluated over the entire recordset but that variable only has a value for 1 record. The formula can't be evaluated for each record except as each record is handled so all the values don't exist.

mlmcc