Hello @Tyagi, Varun (Slalom Consulting) ,
Thanks for the question and using MS Q&A platform.
As I understand the ask is for a way to determine whether you need to add an extra page in your pagination for remainder given number of records, and number of records per page.
While there is no ceiling function, there is modulo function.
The modulo function gets the remainder of integer division.
mod(4,2) => 0 div(4,2) => 2 div(4.0,2) => 2.0
mod(5,2) => 1 div(5,2) => 2 div(4.0,2) => 2.5
mod(220,25) => 20
So when the remainder is more than 0, then you need another page.
Returns true when needs another page
@greater( mod(num_records, 25) , 0 )
Put all together (assuming you are using ints not floats) , replace 200 with your input
@{
if(
greater(
mod(220,25),
0
),
add(1, div(220,25) ),
div(220,25)
)
}
The difficulty I ran into earlier, was the failure of int(2.5)
. I expected this to result in 2
, but got error instead. Since I can't use this, I will have to do string operations if you really need ceiling for some reason.
@{
if(
greater(
length(split(pipeline().parameters.IN2,'.')),1)
,
if(greater(int(split(pipeline().parameters.IN2,'.')[1]),0)
, add(int(split(pipeline().parameters.IN2,'.')[0]),1),
split(pipeline().parameters.IN2,'.')[0])
,
pipeline().parameters.IN2
)
}
Please do let me if you have any queries.
Thanks
Martin
- Please don't forget to click on
or upvote
button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
- Want a reminder to come back and check responses? Here is how to subscribe to a notification
- If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators