COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: BigOCombe on 18 Apr 2013 08:19:02 AM

Title: Ceiling or Somethiing Similar
Post by: BigOCombe on 18 Apr 2013 08:19:02 AM
Hello Group,

In Excel there is a formula called Ceiling that rounds a number up, to the nearest interger or to the nearest multiple of significance. Cognos has a Ceiling function but it only Returns the smallest integer that is greater than or equal to "numeric_expression". So if I have sales of 1, 2, or 3 I would like to round to 4; sales of 5, 6, or 7 round to 8; etc... Any suggestions on how to accomplish this?

Thanks!
BigOCombe
Title: Re: Ceiling or Somethiing Similar
Post by: calson33 on 18 Apr 2013 10:15:09 AM
You could use something like a case statement and mod:

case when mod(sales,4) = 0 then sales
else sales + (4-mod(sales,4))
end
Title: Re: Ceiling or Somethiing Similar
Post by: BigOCombe on 18 Apr 2013 11:31:10 AM
Thanks calson, that work perfect.
Title: Re: Ceiling or Somethiing Similar
Post by: calson33 on 18 Apr 2013 11:38:15 AM
After thinking about it, you don't even need the case statement. just
sales + (4-mod(sales,4)) will do.