
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
syntax to compare BigDecimal if it's greater than x
Hi everyone I'M struggling with the syntax.
I have a field which ist called "achievement", data type BigDecimal.
Inside are values like : 0.756
Now I just want to create a condition in tmap like: if achievement>= 0.7 then 100 else 0
I tried this but something isn't correct:
(row1.achievement.compareTo(BigDecimal.valueOf(>=0.7)))? new BigDecimal(100) : new BigDecimal(0)
Thanks for any hints.
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@pawe84 ,check the below expression.
(row4.newColumn.compareTo(BigDecimal.valueOf(0.7))==1 && row4.newColumn.compareTo(BigDecimal.valueOf(1)) < 0 ) ?new BigDecimal(100 ) : ((row4.newColumn.compareTo(BigDecimal.valueOf(1))==1 && row4.newColumn.compareTo(BigDecimal.valueOf(1.2))<0)?new BigDecimal(200):new BigDecimal(0))

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
firstBigDecimal.compareTo(secondBigDecimal) > 0 // ">"
firstBigDecimal.compareTo(secondBigDecimal) == 0 // "=="
firstBigDecimal.compareTo(secondBigDecimal) >= 0 // ">="
so use:
BigDecimal.valueOf((row1.achievement.compareTo(BigDecimal.valueOf(0.7)>=0)? 100 : 0)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks but when I try this statement I'll get always this error

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@pawe84 ,check the below condition.
row1.newColumn.compareTo(BigDecimal.valueOf(0.7))>=1?new BigDecimal(100) : new BigDecimal(0)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks it's working.
How would the syntax be if there's the following condition
if achievement>=0.7 and <1 then 100
elseif achievement>=1 and <1.2 then 200
else
0
end

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@pawe84 ,check the below expression.
(row4.newColumn.compareTo(BigDecimal.valueOf(0.7))==1 && row4.newColumn.compareTo(BigDecimal.valueOf(1)) < 0 ) ?new BigDecimal(100 ) : ((row4.newColumn.compareTo(BigDecimal.valueOf(1))==1 && row4.newColumn.compareTo(BigDecimal.valueOf(1.2))<0)?new BigDecimal(200):new BigDecimal(0))
