Numeric Overflow in crystal report - crystal-reports

I have a numeric field in my report that I perform the operation
Time({Command.EndTime}/60,Remainder({Command.EndTime},60),0)
on.
Basically the field is a time field but my predecessor used a numeric field to represent it for some unknown reason. The field is the number of minutes past midnight. For example: 60 is 1am, 65 is 01:05 am...) I would like to report it in a form that is more human friendly. However, I got this error "Numeric overflow" and wonder what might have caused it. Normally, the cause of this error is a division by zero but the divisor is clearly 60.
If I just used {Command.EndTime}, the report was fine... The database is huge with millions of records, so scanning the report line by line is only my last resort. Is there a way to know what was wrong in the data or better yet get around the error mentioned above?
Thanks!

The first parameter to Time() has to be a whole number. Try this instead:
Time(Truncate({Command.EndTime}/60),Remainder({Command.EndTime},60),0)

Related

In Grafana, how do we deal with queries that return 0 rows in a chart/panel?

I’m running into a problem that might be self inflicted but I’m a noob and I’m still stumbling thru this dashboard I inherited.
We are using Grafana 8.1.5. I inherited a dashboard with a panel that is giving this error message:
“failed to convert long to wide series when converting from dataframe: can not convert to wide series, input has null time values” error.
I think I know the cause but I don’t know how to fix it. The data source is from a MySQL database. When we select “All” under the dropdown “Org”, we don’t get this error and we get 8 rows back and are expecting 8 rows.
When we select one org (in this example “Data Protection”) under the dropdown “Org”, we do get the error and we get 5 rows back. I think because 3 queries return 0 rows, we are getting this error.
Each pie slice has its own SQL query to get data. For the queries that return 0 rows, I tried selecting some of the “Standard options” to fix it but it doesn’t seem to work. I tried to play around with the Min, Max, and “No Value” settings and enter values larger than 0 but I still get this error. The initial values for Min and Max were "auto" and "No Value" was blank but the screenshot is when I left them as "1" while I was messing with them.
What do I need to do to make the message go away? Is the message benign and I shouldn’t worry about it since it looks like we’re still printing out the pie chart?
Write SQL, which returns record with zero value instead of empty result. In theory zero value, won't be visible in the pie chart and you will have still record for dataframe transformation, so that one won't be failing.
So I accidentally stumbled across the answer. What happened is the query returned data formatted as "Time Series" instead of "Table". Because some of the data didn't have values for the specified time, the time value was Null.
Since it was Null, the chart returned this error message. The fix was to select "Table" as the format. Then the chart won't care about the time value being Null and the missing data appears as 0 in the legend and we don't get the error message anymore.

Crystal reports 2011 Math operations on running total fields

Been trying to do this for hours, so would very much appreciate an answer. Google apparently hasn't heard this question before; in fact, I could find very little information on this subject anywhere, including in the Crystal reports help functions.
I have three running total fields in a Crystal Reports 2011 report. I need to add two of them together and then divide that sum by a third running total field.
Here is what I have in the formula field I have created in order to do this:
(Sum(rtotal1))+(Sum(rtotal2))/(Sum(rtotal3))
The error I continue to get is: The ) is missing
Can anyone tell me the correct syntax for how to do this (aggravatingly simple) operation?
So I'm not sure what your running totals are (sum, count, etc.), but you shouldn't have to specify sum in your formula. I did a quick mock-up with 3 running total fields, each one a sum of a value. the resulting formula looks like this:
({#RTotal0} + {#RTotal1})/{#RTotal2}
I'm not sure if the brackets are needed, but since you want to add RTotal0 and RTotal1 first and then divide that result by RTotal2, I advise to put them in.

Problems converting a crystal reports running total string to a number

I have a problem with converting a running totals string to a number.
The running total is set to retrieve the maximum value of a field that contains results. It is reset with change of a group and evaluated by a formula so that only results from a specific test is used.
The result database field is a string since there are test with text results as well as tests with numeric results in the database. The test I'm filtering out only have numeric results (saved as string).
The running total works fine and gives the correct result, but I want to change it from a string to a number to be able to set the number of decimals and use rounding in the report, and this is where my problem begins.
As far as I can tell there is no way of using the format field in this case. (Which is resonable since it is a string field.)
I've tried using a formula field with the following formula:
if isNumeric({#P-LDL}) then toNumber({#P-LDL})
but that returns 0.00 for all non-null values even though the strings are nice things like "2.36" or "3.74" (without the quotes).
I've also tried the old school approach of resetting a global variable in the group head, assigning it a value in the details section when a post with the correct test comes along, and then finally display it in the group footer, but I get the same 0.00 result. I've tried both using a numeric global variable and do the conversion on the details-level, and using a string variable and do the conversion in the footer-level.
Solved it:
if NumericText(Replace({#P-LDL}, ".", ",")) then
ToNumber(Replace({#P-LDL}, ".", ","))
Stupid locales...

iReport query results break-down by week or day

I have used iReport to create a simple JasperReport which I run on a JasperServer. It queries some fields from a number of MySQL tables based on their creation timestamp. I am providing the start and end timestamps of the period to cover in the report as parameters of type java.sql.Timestamp. This works fine.
I was asked to introduce the ability to show a break-down on weeks or days of the report data. I would like to get some ideas on where to start with this. At this point I don't think I can accommodate this 'break-down' in the report query, since this feature seems beyond what SQL is designed to do. I know this sounds like an OLAP drill through, but I would like to avoid OLAP if possible (steep learning curve, tight deadlines).
My first thought was to create a subreport for each week or day . But this would leave me with an arbitrary number of subreports (depending on the overall time period covered by the report, which varies at each execution), and as far as I can tell iReport does not support this.
Here is one way to break the report down.
Create another parameter, groupby, which holds the a value that designates the grouping requirement. The values can be numeric, string or whatever else as long as it corresponds to day, week, month, etc.. grouping available.
Create a report group, breakdown, which will provide the breakdown. The group expression will depend on the groupby parameter. The expression is the date on the record except any detail finer than groupby value will be trimmed.
Create a variable, total, that will sum the data in the records. The variable should be reset on breakdown group and can be printed in the breakdown trailer band.
Make sure the sql queries sortby the date so that the groupby expression works.
Let me know if you have questions.

Zend_Search_Lucene and range search

I have a bunch of int key fields in my index and trying to do a simple range search like this:
`gender:1 AND height:[120 TO 180]`
This should give me male in the height range 120 to 180. But for some reason i get this exception:
`At least one range query boundary term must be non-empty term`
How would i debug this? Is it just Zend_Search_Lucene being buggy?
This is an open bug in the query parser of the Zend Framework. Created in december 2008 with high priority... and still unsolved.
First, you have to change default Analyzer to TextNum to allow number before finding
ZF2:
\ZendSearch\Lucene\Analysis\Analyzer\Analyzer::setDefault(new \ZendSearch\Lucene\Analysis\Analyzer\Common\TextNum\CaseInsensitive());
Second, your date field MUST be a keyword, not text.