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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
RA6
Creator
Creator

Issue while rounding value

Hello guys,

I have an input file delimited and i need to divide the number of records (tFileRowCount_2_COUNT) by 4 in a tjava component.

I need the below expected result. Can someone help on this please?

0695b00000SprQQAAZ.png

0695b00000SprPrAAJ.png

Note: my context variable (context.nombre_ligne) is of type integer.

Best regards,

RA

Labels (3)
1 Solution

Accepted Solutions
gjeremy1617088143

cast your integer as a double and it will work

 

View solution in original post

4 Replies
gjeremy1617088143

Hi @Rohit Aftab​ , if you want to round up, try the method Math.ceil() instead of Math.round().

Send me love and kudos

RA6
Creator
Creator
Author

it is not working :

 

context.nombre_ligne = (int)java.lang.Math.ceil(((Integer)globalMap.get("tFileRowCount_2_COUNT")/4));

System.out.println(context.nombre_ligne);

 

10records / 4 => i have result => 2

it should have been 3.

 

Best regards,

RA

gjeremy1617088143

cast your integer as a double and it will work

 

InfoCraft
Creator
Creator

Hi @Rohit Aftab​,

 

(int) Math.ceil(row7.records/4.0)

 

context.nombre_ligne = (int) Math.ceil(((Integer)globalMap.get("tFileRowCount_2_COUNT")/4.0));

System.out.println(context.nombre_ligne);

 

Kind regards,

😷