Page 1 of 1

CEILING and FLOOR functions

Posted: Fri Feb 05, 2021 3:29 pm
by 20 Ton Squirrel
TM1 lacks the CEILING and FLOOR functions but I recently set about emulating them formulaically. I hope posting this here helps someone in the Distant Dark Futureā„¢

Code: Select all

[ 'Ceiling' ] = N: 
    ( INT ( [ 'Value' ] \ [ 'Significance' ] ) 
     - IF ( [ 'Value' ] \ [ 'Significance' ] - INT ( [ 'Value' ] \ [ 'Significance' ] ) > 0 
           , -1
           , 0
          ) 
    ) * [ 'Significance' ] ;
    
[ 'Floor' ] = N:  
    INT ( [ 'Value' ] \ [ 'Significance' ] ) * [ 'Significance' ] ;

Re: CEILING and FLOOR functions

Posted: Fri Feb 05, 2021 4:54 pm
by jim wood
You should put this in the useful code section of the site. It's very useful and in the main forum it will get moved down quickly. Let me know if you'd like it moved over there?

Jim.

Re: CEILING and FLOOR functions

Posted: Fri Feb 05, 2021 5:41 pm
by 20 Ton Squirrel
Sure! Scoot it on over there. Thanks, Jim! :)