[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Crystal Formula

Posted on 2014-01-07
6
Medium Priority
?
469 Views
Last Modified: 2014-01-14
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
0
Comment
Question by:BananaFury
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 39762074
Create 3 formulas
Formula 1 - CntInformedRes
if date({Archive_tblEvents.TableDate}) = today and {Archive_tblEvents.SubStatusGroup} = "Accepted - Informed Reserve" then 
    1 
else 
    0

Open in new window


Formula2 - SumInformedRes
if date({Archive_tblEvents.TableDate}) = today and {Archive_tblEvents.SubStatusGroup} = "Accepted - Informed Reserve" then
    {Archive_tblEvents.OutstandingReserves} 
else 
    0

Open in new window


Formula 3 - MySummary
Sum({@SumInformedRes}) / Sum({@CntInformedRes})

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
0
 

Author Comment

by:BananaFury
ID: 39764476
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?
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 300 total points
ID: 39765162
You might be able to do it with running totals but it would take one for formula 1 and one for formula 2.

The problem is you are filtering the records based on data in them to determine if the should be included in the summary.  Summary functions work on ALL records and don't have a way of limiting them.

DO you need the records, the filter is eliminating from the count and sum for the rest of the report?
If not you could eliminate them through the select expert.

mlmcc
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:BananaFury
ID: 39765531
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.
0
 
LVL 35

Assisted Solution

by:James0628
James0628 earned 300 total points
ID: 39766102
You might be able to do it with weighted averages.  I've never really used them myself, so I'm not sure about it, but I think they might work.

 You'd still need a "count" formula for each condition, like CntInformedRes, but they don't need to set a variable.  They just need to produce a 1 if the conditions are met, or 0 if they are not.  IOW, they'd be like the first formula in mlmcc's first post.  That's your "weight".

 Then right-click on the field to be averaged (eg. OutstandingReserves), select Insert > Summary and select "Weighted average with", and then select the count (ie. weight) formula below that.  And, of course, select the summary level (grand total or whatever).

 You could give that a try.  If it works, then you've only got one "count" formula for each condition to maintain.

 James
0
 

Author Closing Comment

by:BananaFury
ID: 39778555
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
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question