Solved

Round Up Calculated Field or Format Expression in Report Builder 3.0

Posted on 2014-02-06
7
5,803 Views
Last Modified: 2014-02-08
I'm attempting to use the DateDiff function to identify the number of minutes between two date time fields.  I need it round up to the next whole number.

My formula to count the number of minutes is as follows
=(DateDiff(DateInterval.Second,CDate(Fields!Time_First.Value),CDate(Fields!Time_Second.Value)))/60

The formula is working fine and resulting the correct number of minutes, but my problem is the rounding.  If the duration is 1.1 minutes, then I need it to round up to 2.  The basic rounding available in Report Builder 3.0 rounds in the traditional .01 t .49 down and .5 to .99 up.

Any suggestions would be greatly appreciated.  I'm looking for a calculated field or a format expression type of solution.
0
Comment
Question by:jaisy99
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 26

Expert Comment

by:Chris Luttrell
ID: 39840207
in T-SQL you could use CEILING(x) to return the next integer, CEILING(1.1) yields 2.
I am not sure if you can use that command in Report Builder or not and do not have a test environment to test it first, sorry.
0
 
LVL 12

Expert Comment

by:Tony303
ID: 39840262
I wonder if you can apply the MRound type Excell function like this description below....
I guess you'd multiply 25 and divide by 25? (ie. 5 tmes the example given or .2)



•The Round function is useful to round numbers to the nearest integer. The following expression rounds a 1.3 to 1:
 
= Round(1.3)
 
You can also write an expression to round a value to a multiple that you specify, similar to the MRound function in Excel. Multiply the value by a factor that creates an integer, round the number, and then divide by the same factor. For example, to round 1.3 to the nearest multiple of .2 (1.4), use the following expression:
 

= Round(1.3*5)/5


Having said that, I'd prefer to do the calcs in SQL first, then have that field pumped through into SSRS.
0
 
LVL 1

Author Comment

by:jaisy99
ID: 39840263
Thank you, tried ceiling, but looks like it won't take it and results in error.  Finally got it to work but it is three separate calculated fields.  It errors if I try to combine the last two calculated fields.  This will work for now.  But if anyone has an easier way, would like to use it.  
Thank you for your help.

Final solution that worked is:
Calculated Field 1 (see above)
Calculated Field 2 =INT (Fields!Calculated_Field_1.value)
Calculated Field 3 = Fields!Calculated_Field_2.value + .5
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 12

Expert Comment

by:Tony303
ID: 39840344
Good on you,

I think though, doing the Ceiling in SQL is a better option.

T
0
 
LVL 37

Accepted Solution

by:
ValentinoV earned 500 total points
ID: 39841183
SSRS also has a Ceiling implementation.  Here's how that would go:

=Ceiling(DateDiff(DateInterval.Second
  , CDate(Fields!Time_First.Value)
  , CDate(Fields!Time_Second.Value)) / 60)

Open in new window

0
 
LVL 1

Author Closing Comment

by:jaisy99
ID: 39843744
This was exactly what I was looking for.  Thanks to all.
0
 
LVL 37

Expert Comment

by:ValentinoV
ID: 39844023
Glad to have been of assistance, enjoy the weekend!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hello, In my precious Article  (http://www.experts-exchange.com/Database/Reporting/A_15280-Create-Project-in-Microstrategy-Part-I.html)we saw the Configuration part for Microstrategy which included Metadata Creation and DataSource Preparation as …
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now