Is there is 'if integer' or similar statement in Crystal Reports? - crystal-reports

I'm trying to find a way to check if the result of a calculation in a formula is a whole number (integer) when divided.
I have had a look through the functions present in Crystal, but I cannot find anything along the lines of what I am looking for.
So far my code looks like the below
If {#recordnumber} / 12
//is an integer (not a decimal) | Here is where i am stuck as how to do
this
Then opNo12 else
So ideally say the record number is 144, or any other multiple of 12, I want the formula to return opNo12.
If anyone can clear up if this is possible or alternatively point me in the right direction for a solution it would be greatly appreciated.
Thanks

Try something like this:
if Trunc({#recordnumber}/12) <> ({#recordnumber}/12)
then
opNo12
else ""

IF {#recordnumber} mod 12 = 0 Then opNo12 else ""

Related

how to fill na with a specific value based on a condition

Still learning python, and struggling with dates and na's.. I have a situation as the image below would show
enter image description here
for the NAT values in the column EndDT_New, i would like to fill them with a specific value based on a condition, eg:
if the DATE_ACT_CLOSED = '01/01/2040' then replace just the NAT in EndDT_New with 30/03/2021 else
if the DATE_ACT_CLOSED <> '01/01/2040', then replace just the NAT in EndDT_New with the value in DATE_ACT_CLOSED .
My previous experience is in SAS, so its quite a learning curve and mind shift to python.
Any help is much appreciated.
Kind Regards,
i reckon i figured it out.
df_all_valid.loc[(np.isnat(df_all_valid['EndDT_New'])==True) & (df_all_valid['DATE_ACT_CLOSED'] == '01/01/2040'), 'EndDT_New'] = np.datetime64('2021-03-30')

Having trouble combining 2 functions

I am currently a student in high school. Due to the fact that my state is on complete shutdown because of the whole COVID-19 crisis that is going on. I am trying to add 2 functions into a range of cells to further organize myself while trying my best to stay organized doing school from home.
Function 1: =DAYS(E:E,TODAY()) Count how many days left to complete an assignment.
Function 2: =IF(E:E=-1, "PAST DUE") If the amount of days left equals -1, it will change the cell text to "PAST DUE".
The only problems I am having is A: Combining 2 functions, and B: making the IF statement work. If there is any way you could help me out, then please try. It would mean a whole lot.
=IF(DAYS(E:E,TODAY())<0, "PAST DUE", DAYS(E:E,TODAY()))
If {days left} is less than 0, then return "PAST DUE". Otherwise, return {days left}
Something like this?
=IF(DAYS(E:E,TODAY())<=-1, "PAST DUE", DAYS(E:E,TODAY()))
try for array:
=ARRAYFORMULA(IF(DAYS(E1:E, TODAY())<0, "PAST DUE", DAYS(E1:E, TODAY())))

Crystal Reports Using an IF formula with summary of summary fields

I cannot find a solution or workaround that applies to my problem.
I have a complex report that includes several calculations at different levels.
GroupLevel4, which is ({Command.START_TIME}, "by second") has a formula field -- lets call it {Formula_Field1}.
It is defined as:
If DistinctCount ({Command.RECORDED_TIME}, {Command.START_TIME}, "by second") >= Maximum({Command.DOCS_NEEDED}, {Command.START_TIME}, "by second")
then 1 else 0.
It returns either 1 or 0.
Now I want to create a formula at Group3 level that says:
If Sum({Formula_Field1}) >= Maximum({Command.DOCS_NEEDED}, {Command.ID})
then 'Y' else 'N'
However, I can't summarize Formula_Field1 because it's based on something that is already a summary. I feel like I've tried everything. I tried some suggestions I found about declaring variables, but I think they were more specific to a straightforward sum of a sum.
Any suggestions are appreciated.

Crystal Formula to exclude if value does not contain a certain format

I'm trying to exclude any value from a certain field (table.value) that does not match this format AA#####A. Example if they entered APT12345T, or PT12345PT and No Value then I want to exclude it from the report. It needs to match example AP12345P. What selection formula can I use to accomplish this.
Any help is greatly appreciated
Thanks in advance.
try reading Crystal's help topics on the mid() and isnumeric() functions.
here's an example from the help file:
Examples The following example is applicable to both Basic and Crystal
syntax:
Mid("abcdef", 3, 2)
Returns "cd".
so, in your case, you want to strip your value into three pieces,
mid(table.value,1,2)
mid(table.value,3,5)
mid(table.value,8,1)
and build up a three-part boolean variable where:
the first piece is not numeric(), or between 'AA' and 'ZZ', or however
else you want to test for letters,
the second part isnumeric(), and
the third part passes the same test as the first part.
where are you getting stuck?
something like this:
not isnumeric(mid({table.field},1,2)) and
isnumeric(mid({table.field},3,5) and
not isnumeric(mid({table.field},8,1))

Else part never getting executed in crystal report formula field

I have a simple formula in crystal syntax which looks something like this :
if isdate(totext({Absence Details.Return to Work Interview Date})) = true
and {Absence Details.Return to Work Interview required} = true then
1
else
0;
This is the actual code of the formula
but the else part is never getting executed, when the condition is not true report just shows blank. I am not sure what I am doing wrong here.
Thanks in Advance.
- Amit
Maybe you have some null value in your fields - in such case crystal just returns null. You then need either "convert null values to default" setting for report or explicit testing against nulls.
Edit: NM, code was posted to the comments. Doesn't look like this is the issue.
My guess, assuming you've debugged correctly is that you've got a semicolon somewhere you shouldn't.
if {something} = x then
do something;
else
do something different;
instead of
if {something} = x then
do something
else
do something different;
This would cause the behaviour, assuming it doesn't choke on the orphaned else clause. But as the comments say, short of posting real code, we can only guess at what's going on. It could be as simple as your evaluation is always true.
Change the 0 to a 7 and see if it actually prints 7. Some report generation tools (and I have little experience with Crystal but quite a bit with others) will leave fields blank if they're zero - this often helps in reading the report by reducing unnecessary clutter.
If the 7's print out, then that's what the problem is, and it's a matter of figuring out how to get Crystal to output an actual 0.
That may be a matter of configuring the output field or even stting it to a textual "0" instead of numeric 0.
Of course, if that doesn't print out 7's, then feel free to let me know.