Jump to content
  • Using CEILING and FLOOR Functions in the Calculated Measures


    Dhiraj Pahlani
    • Edited on:
    • Features: Ad Hoc Version: v9.0.0 Product: JasperReports® Server

    Requirement:
    When I go to the create Ad Hoc View > Select Domain > Create Measure a list of functions is available that I can use to create a formula. However, I do not see a function available for CEILING or FLOOR.

    The closest function available is the ROUND function which round off to the next integer when the decimal is more than half (e.g.1.6 is rounded of to 2). Whereas Ceiling rounds off to next integer if it is greater than 0 (e.g. 1.3 is rounded of to 2).

    Is such functionality possible in Measures?

    Solution:
    Yes, this is possible by creating custom Measures to simulate these DB functions. We can use the following formulae in the Ad Hoc custom Measures to achieve this requirement.

    CEILING
    Round("field"+0.5, 0)

    FLOOR
    Round("DecimalId"-0.5, 0)

    See below screenshots for reference.

    image.thumb.png.6a235937e04d13369992c08ccbf0833d.png

    Floorfunction.thumb.png.885e2ccb95774adb9f6d719ec47ac8ee.png

    Viewdisplay.thumb.png.065f2b9a3da40bba87a8b13a7d6fa83b.png

    ___________________________________________________________________________________________________________________________________________
    Ref. Case #02273187


    User Feedback

    Recommended Comments

    There are no comments to display.



    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

×
×
  • Create New...