I have a report that is counting a specific event with a running total. In the group footer, I want to suppress the footer if the count is not a specific value (RTotal0 <> 5) AND if the most recent occurrence of the event is not within the last seven days (datediff("d", EventDate, Currentdate) >7).
Either of these conditions works by themselves, but if I combine using an "AND" statement, only the datediff condition is evaluated; the RTotal condition is ignored. Any ideas? Here's my suppression formula:
{#RTotal0}<>5 and DateDiff ("d",{EVENT-DATE},CurrentDate) >7
Thanks
Found this format finally worked:
not ({#RTotal0}=5 and DateDiff ("d",{EVENT-DATE},CurrentDate) <8 )
Related
I have a formula which uses DateDiff to find out the difference between two dates and excludes the weekends.
I'd like to then use that DateDiff in another formula to calculate averages based on and if/then criteria.
When I put average({date diff formula}) I receive an error of "Invalid Argument was encountered"
I can't use the date diff formula in any formula I try to use it in, is there a reason for this?
Example DateDiff formula:
DateDiff('d',*datecolumn*,today)
Then pass that thru into your running total, eg:
Make a grouping in your group expert for the set you wish to summarize with an average, select that group in the Evaluate section and, if desired, in the Reset as well.
Let me know if this isn't quite it for you, good luck!
New to Crystal Reports -
I have a report with 3 columns - Estimated Hours, Actual Hours, Remaining Hours.
In the Group Footer it summarizes the hours by job. The remaining hours formula is {job.esthours}-{job.actualhours}. I want it to be blank if there is no estimated hours. I know that I can't use the sum of estimated hours in my formula but not sure what formulas to use.
Sample Report
You need to add a condition to suppress your formula in case the first cfield value is null. You can do it in two ways:
1) Add the condition in your Remaining Hours formula. Try this if you want blank also in your detail sections. Right-Click -> Suppress -> add there the next condition:
if(isnull({job.esthours}))
2) Add the condition in your Remaining Hours Summary. This is better if you wish to show negative values of Remaining Values in your Details Section for some reason. Right-Click -> Suppress -> add there the next condition:
if(isnull(sum({job.esthours})))
And yes, you can use the estimated hours summary, , you can find it in your Formula workshop, in the Report Fields tree
i want to filter my rows and only select/ display my rows when the field AMSD135.AB is the latest date date in that group.
So i got a report with some groups where the last group is grouped on AMSD135.AB. Now i created a formula to hide the section.
AMSD135.AB <> Maximum({AMSD135.AB}, {AMSD135.AB})
but i always get the following error message:
There must be a group that matches this field.
if i use
AMSD135.AB <> Maximum({AMSD135.AB})
it searches for the max in all rows.
It works when i use the following formula:
{AMSD135.AB} <> Maximum({AMSD135.AB},{Arbeitsgang.AGNR})
with {Arbeitsgang.AGN} being the group above. Which makes more sense, since when i group by AB, Max(AB) is always AB. But shouldnt it still work.
I have seven dates on my crystal report.I need to compare month of each date with the date the report is made to run(#Datebeg is the field for report date).
I am using formula on my report as
if month({Date1})=month(cdate({#Datebeg})) and
month({Date2})=month(cdate({#Datebeg})) and
month({Date3})=month(cdate({#Datebeg})) and
month({Date4})=month(cdate({#Datebeg})) and
month({Date5})=month(cdate({#Datebeg})) and
month({Date6})=month(cdate({#Datebeg})) and
month({Date7})=month(cdate({#Datebeg}))
then (H1+H2+H3+H4+H5+H6+H7) else 1.
The output I am getting is 1,each time.The months are not getting compared at all.If I put OR instead of AND,that gives me sum of all H(1..7).
Please help me with the comparison.
Thanks in advance.
go ahead and create 7 formulas and put a condition per formula, for example:
#Formula1
month({Date1})=month(cdate({#Datebeg}))
#Formula2
month({Date3})=month(cdate({#Datebeg}))
so on and so forth. Place those formulas in you report header and run the report. In that way you can see the behavior of each condition and troubleshoot it. Those formulas are going to return True or False, True when they meet the criteria and False if they don't.
Hope that helps!
I am trying to figure out the best way to display the daily average of a count by month.
Here is what the data looks like
Date(date),Location(string),UnitID(string)
2011-12-1,A,123
2011-12-1,A,456
2011-12-1,B,789
2011-12-1,B,246
2011-12-2,A,135
2011-12-2,A,123
2011-12-2,B,789
2011-12-2,B,468
...
We would like a report showing the following:
(location) 12/2011 1/2012 2/2012 (by month)
A 12.5 10.3 14.0
B 22.1 20.9 25.6
The summary fields should be calculated following this general idea for each month/location combination:
Avg(Count(UnitID))/(days in month) *see below for clarification, this formula doesn't really make much sense.
The Avg(Count(UnitID)) is the tough part. A cross tab would work best, but anything at this point will work.
Any help is greatly appreciated.
Edit for clarity: The data is a listing of all units that had a failure. Several Units per day fail, spread out over several locations. In English what I want is the average daily number of failures of units per month, grouped by location.
I recommend doing this in a crosstab.
First, add a formula (called something like perMonthCount) like the following to the report:
1 / DatePart ("d",
DateAdd ("d",
-1,
DateAdd ("m",
1,
DateAdd ("d",
1-DatePart ("d", {failures.fail_date}),
{failures.fail_date}) ) ) )
Next, select Insert > Cross-Tab... from the menu and specify the following values in the Cross-Tab tab of the Cross-Tab Expert dailog:
Rows: your location field
Columns: your failure date field (use the Group Options button to specify that the column should be printed for each month, instead of the default for each day.)
Summarized Fields: the #perMonthCount formula field (the summary operation should default to Sum of.)
In the Customize Style tab of the Cross-Tab Expert dailog, check the Suppress Row Grand Totals tick-box. (You may also want to check the Suppress Column Grand Totals tick-box, if you don't want to see totals for all locations at the end of the report.)
Click on OK at the bottom of the Cross-Tab expert dialog and drop the Cross-Tab into the report footer.
You will also probably want to suppress the details section of your report.
At this stage, you should now be able to preview your results.