Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

increment a Big Dec context variable in tMap

Hi

I am trying to conditionally increment a Big Dec context variable based on certain field values 

currently I can do this via tJavaRow component, but want to bring this into a tMap - so the logic is centralized

 

this code currently works in tJavaRow 

 

 

0683p000009LrLv.png

but when I try to code something similar in the Var Expression builder, I receive "Type mismatch: cannot convert from Number&Comparable<?> to BigDecimal"

0683p000009LrKe.png

 

I have tried to search online in several places to address this issue but have had zero luck

do you have any advice

 

thank you in advance

Labels (3)
1 Solution

Accepted Solutions
TRF
Champion II
Champion II

Hi,

Not very clean in my opinion, but if I understand your request you should try this.

Create a BigDecimal variable in the tMap, enter the expression builder and type the code:

null; // This is here because you need to affect a value to the variable
if(!"A".equals("B")) // Replace this with your condition
	context.test = context.test.add(new BigDecimal(1)); // Replace with your context variable

As you can see, the expression builder can be used to enter a piece of Java code which is not used for the variable assignment.

The only rule is that the 1st line must reprsent the right part of the variable assignment, but of course, you are not forced to use this variable anywhere.

So, this is what you expect: the context variable is incremented by 1 for each input row under condition.

Hope this helps.

View solution in original post

4 Replies
Anonymous
Not applicable
Author

In your expression remove "context.LastName_NullCount ="
In line 3 as shown in picture
TRF
Champion II
Champion II

Hi,

Not very clean in my opinion, but if I understand your request you should try this.

Create a BigDecimal variable in the tMap, enter the expression builder and type the code:

null; // This is here because you need to affect a value to the variable
if(!"A".equals("B")) // Replace this with your condition
	context.test = context.test.add(new BigDecimal(1)); // Replace with your context variable

As you can see, the expression builder can be used to enter a piece of Java code which is not used for the variable assignment.

The only rule is that the 1st line must reprsent the right part of the variable assignment, but of course, you are not forced to use this variable anywhere.

So, this is what you expect: the context variable is incremented by 1 for each input row under condition.

Hope this helps.

TRF
Champion II
Champion II

Does this help?
If so, please mark the case as solved.
Kudos also accepted.
Anonymous
Not applicable
Author

TRF

thank you 

this works - sorry for not responding to you sooner

your efforts are much appreciated