Announcement

Collapse
No announcement yet.

Round Function specifics in a formula?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Round Function specifics in a formula?

    Hello all, I have a question regarding the round() function. What I want to do is this: for every number (in this case, X), I always want X.01 - X.49 to round down, and X.50 to X.99 to round up. In fact, even better would be this:
    • X.01 to X.24 would round to X.00
    • X.25 to X.49 would round to X.50
    • X.51 to X.74 would round to X.50
    • X.75 to X.99 would round to Y.00 (Y being the number above)

    If I am interpreting the round() function correctly, you have to call out these roundup/rounddown functions individually, for each number. What I'm trying to do is round up or down discharge or return openings that aren't exactly to the half inch. You have to define each duct size in Revit, and it's not reasonable to add a 12-3/16" wide by 10-5/8" tall duct size for the Duct Connector itself just for an anomaly from an equipment manufacturer. This would be excellent for BOM takeoffs of things like canvas connectors, transition pieces, etc. So I'd like to have a roundup/rounddown function that applies for all numbers for the ranges I listed above.

    Thanks in advance!

    -TZ
    Tannar Z. Frampton ™
    Frampton & Associates, Inc.

    #2
    You have to call them out individually, but can stack them in a formula. I think there are a couple ways to do this, and haven't tested it, but I think I'd try something like:

    =if(X<(rounddown(X)+0.25), rounddown(X), if(X<(rounddown(X)+0.75), rounddown(X)+.05, rounddown(X)+1))
    Julie Kidder
    Architect + BIM Director
    Hartman + Majewski Design Group

    Comment


      #3
      Thanks jmk. I'm wondering if a parameter with an if() statement of a range of numbers could capture all numerical values and use that output value in a roundup/down nested formula? I feel like there's got to be a way. And thanks for the response!

      -TZ
      Tannar Z. Frampton ™
      Frampton & Associates, Inc.

      Comment


        #4
        Are you looking for an alternate method, TZ? I'd imagine jmk's formula will do what you need it to do.
        Developer at Anguleris BIMsmith Marketplace.
        Previously at Sumex Design for ARCAT.com

        Comment


          #5
          It does do as described in the original post, as long as you change the bit that says .05 to .5 in the original post... Nested if statements work from left to right, so it tries the first condition and ends the test if it is true. Attached is an empty generic model with the corrected formula.

          =if(X<(rounddown(X)+0.25), rounddown(X), if(X<(rounddown(X)+0.75), rounddown(X)+0.5, rounddown(X)+1)

          You can of course substitute another parameter for the repeated element if you need to use it elsewhere.
          Attached Files
          Last edited by jmk; March 1, 2017, 08:21 PM. Reason: Added corrected formula
          Julie Kidder
          Architect + BIM Director
          Hartman + Majewski Design Group

          Comment


            #6
            You want to round to the nearest .5; that can also be written as: =round(x/.5)*.5 or =round(x*2)/2
            Chris Ellersick

            Comment


              #7
              Originally posted by jmk View Post
              It does do as described in the original post, as long as you change the bit that says .05 to .5 in the original post... Nested if statements work from left to right, so it tries the first condition and ends the test if it is true. Attached is an empty generic model with the corrected formula.

              =if(X<(rounddown(X)+0.25), rounddown(X), if(X<(rounddown(X)+0.75), rounddown(X)+0.5, rounddown(X)+1)

              You can of course substitute another parameter for the repeated element if you need to use it elsewhere.
              Excellent, jmk! This is working to perfection. This is going to be a great asset to BOM ordering for takeoff sizes that are not to the inch or half inch in size. It will allow the opening size to be exactly what the submittal shows, but the duct to always adhere to the size based off a few round up/down rules, which will make the Duct Connector in Revit very, very happy.

              Thank you a bunch for your help. Can't wait to implement.

              -TZ
              Tannar Z. Frampton ™
              Frampton & Associates, Inc.

              Comment


                #8
                Wanting to round to specific numbers, I have attempted to mimic an Excel formula with a calculated value in a Revit schedule. Is this correct?

                Excel formula:
                =IF(T5+2>12,CEILING(T5+2,5),CEILING(T5+2,2))

                Revit Formula (number):
                if(Length / 1' + 2 > 12, roundup(Length / 1' / 5) * 5 + 2, roundup(Length / 1' / 2) * 2 + 2)

                (The Length / 1' converts Length data type to Number data type)

                Comment

                Related Topics

                Collapse

                Working...
                X