Avatar of Sue Taylor
Sue Taylor
Flag for United States of America asked on

SQL Calculated Field CEILING or ROUNDUP

SSRS 2012 - Visual Studio 2012 - SQL 2012
I have a field called "Trend" and a field called "Multiplier" that I was to multiple together.  Then I need to take the sum of those two fields and roundup to a multiple of a field called "Inv_Max"

For example:  Trend is 1572 and multiplier is 3.  (1572 * 3 = 4716)  The Inv_Max field is 2400 so I want to roundup the 4716 to 4800, which is a multiple of Inv_max.

I want to be able to add a calculated field and can't figure out the formula.
Microsoft SQL ServerMicrosoft Server OSSSRSSQL

Avatar of undefined
Last Comment
Mark Wills

8/22/2022 - Mon
slightwv (䄆 Netminder)

I assumed integers for the data types.  If they aren't you can probably remove the CAST.

Logic is:  multiply them then divide.  Round up the remainder and multiple that by the max again:
select ceiling(cast(trend as float)*cast(multiplier as float)/inv_max)*inv_max from your_table;
ASKER CERTIFIED SOLUTION
Mark Wills

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy