how to use divide() method in jasper reports? - jasper-reports

Im using iReport1.3.3 tool to create pdf and xls template ..
My problem is for the below expression,
($V{strloanNo}).divide($V{loanCalculation})
i need to divide both the variables but i am not getting expected result. it is displaying "null" value .
any idea guys?

$V{x}.divide( $V{y} )
This works for me.
It looks like your variables are Null.
Make sure to set the Initial Value Expression in the variable's properties.
I set both of mine to below.
new java.math.BigDecimal(10.0)

Guess you can try this out -
$V{strloanNo}.floatValue()/$V{loanCalculation}.floatValue()

As it was discussed
here, you can check this:
$F{Attribute_a}.divide($F{Attribute_b}, new MathContext(100))
If your division results in a non-terminating decimal then an exception is thrown. So you scale simply it to something reasonable and exception be gone.

$F{Attribute_a}.divide($F{Attribute_b})
and class type should be java.math.BigDecimal
if attribute b is zero, please put the condition

Related

Is there way to customize col_max value without change python-click source code?

I'm facing a very concrete problem with python-click 8.1.3. The helptext created by Click wastes too much column space when an option name is a tad long. Depicted in picture below:
I trace into Click's source code, and pinpoint a hardcoded value in HelpFormatter.write_dl(), the col_max parameter determines first-column max-width, which is 30, and I hope to reduce it to 16.
As a Click-library user, how can I achieve this without modifying Click's source code? Maybe some class inheritance or patching trick?
Thank you in advance.
You can do something like this:
class MyHelpFormatter(click.HelpFormatter):
def write_dl(self, rows, col_max=5, col_spacing=2):
super().write_dl(rows, col_max, col_spacing)
click.Context.formatter_class = MyHelpFormatter
Check this answer for a similar example

How to use In operator for comparing multiple values in EXCEL with Drools

I am trying Drools excel to compare some values of products like I have P1,P2,P3...P10 Now I am comparing it with incoming value from request.
I tried in below way but I am receiving an error.
Can you please help to fix this issue. Hope I am making a simple mistake but not able to find it.
Thanks in advance.
You have too many parentheses.
The value in the product column is substituted as is into $param. The correct syntax we're looking for is ... in ("P1", "P2"); however you've provided ("P1", "P2") as the product value. This transforms to in (("P1", "P2")), which is not correct.
Remove the parentheses from the product cell: "P1", "P2".

Gremlin: toLowerCase() not working properly

I have a vertex called 'city' that has property [cityName] "Miami" and property [syonyms] "Miami^Magic City^Little Cuba".
The following query returns no results:
g.V().hasLabel('city').has('syonyms',filter{it.get().toLowerCase().contains('Miami')})
While this query gives me the results that I want:
g.V().hasLabel('city').has('syonyms',filter{it.get().toLowerCase().contains('miami')})
I thought that the "toLowerCase()" would convert "Miami" into all lower case, but it doesn't seem to be doing that. Any ideas?
Adding toLowerCase() at the end of the value within "contains" solved the issue.
g.V().hasLabel('city').has('syonyms',filter{it.get().toLowerCase().contains('Miami'.toLowerCase())})

Running a query using date from a form MS Access

How do I run a query using a value from a textbox from a form I have? I know that there is another post here at Stackoverflow dealing with this issue but I found it to be insufficient for my needs.
I formated my textbox into Medium Date format with its default value being =Date(). However, when I pick up a date and open my report I get this error:
Runtime error 3071: Expression Too Complex
My where clause is this
WHERE
(
(AllInfo.DateOpened >= CDate([Forms]![Main Form]![WindowPrintOptions]![CustomizedReport]!txtDateOpenedFrom.Value))
)
and I am sure it is this code piece that is throwing the problem since when I take it out of the query the error message simply disappears.
Any ideas?
Try with:
(AllInfo.DateOpened >= DateValue([Forms]![Main Form]![WindowPrintOptions].[Form]!txtDateOpenedFrom))
)
Folks,
I got the problem. It was the "AllInfo" alias. It wasn't applicable at that escope inside the query. By changing the proper things, it was enough to write:
[Forms]![Main Form]![WindowPrintOptions]![CustomizedReport]!txtDateOpenedFrom.Value
Issue solved. Thank you all!

Count if SSRS in textbox

I have a scenario where I need to calculate a percentage based on
- No of records with a certain value/ Total no of records.
This is going into a textbox in the header. I am trying the following but I keep getting an error saying "Argument not specified for parameter FalsePart of Pulbic Function Iif.
Can anybody shed some light on this please?
=Count((Iif((Fields!Confirmed.Value, "KPI_Calculation")= True,1,Nothing)),"KPI_Calculation")
/Count(Fields!Confirmed.Value, "KPI_Calculation")
Thanks.
This worked for me in a simple test:
=Sum(IIf(Fields!ConfirmedValue.Value, 1, 0), "KPI_Calculation") / CountRows("KPI_Calculation")
It looks like in your above example you're declaring a Scope too many times and hence getting a syntax error.