Error when rounding to nearest 10 in SSRS Expression









up vote
0
down vote

favorite












I've searched the existing threads and can't figure out where I'm doing it wrong...



I'm trying to get the average of two values and then round the average to the nearest TEN (10).



My expression is:



=ROUND((Fields!Cyl1Stress.Value + Fields!Cyl2Stress.Value) / 2, -1)


The above returns an error.



Rounding to the nearest TENTH works fine, but as soon as I change the 1 to -1, I get the error.



Where Cyl1Stress.Value = 7600 and Cyl2Stress.Value = 7490.



=ROUND((Fields!Cyl1Stress.Value + Fields!Cyl2Stress.Value) / 2, **1**) 


The above code returns 7545.



But I need the result to be 7550, so I change my formula to:



=ROUND((Fields!Cyl1Stress.Value + Fields!Cyl2Stress.Value) / 2, **-1**). 


This one returns an error.



Can't figure out why this isn't working!



Text Box Properties are Numeric, 0 decimal places.










share|improve this question



























    up vote
    0
    down vote

    favorite












    I've searched the existing threads and can't figure out where I'm doing it wrong...



    I'm trying to get the average of two values and then round the average to the nearest TEN (10).



    My expression is:



    =ROUND((Fields!Cyl1Stress.Value + Fields!Cyl2Stress.Value) / 2, -1)


    The above returns an error.



    Rounding to the nearest TENTH works fine, but as soon as I change the 1 to -1, I get the error.



    Where Cyl1Stress.Value = 7600 and Cyl2Stress.Value = 7490.



    =ROUND((Fields!Cyl1Stress.Value + Fields!Cyl2Stress.Value) / 2, **1**) 


    The above code returns 7545.



    But I need the result to be 7550, so I change my formula to:



    =ROUND((Fields!Cyl1Stress.Value + Fields!Cyl2Stress.Value) / 2, **-1**). 


    This one returns an error.



    Can't figure out why this isn't working!



    Text Box Properties are Numeric, 0 decimal places.










    share|improve this question

























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I've searched the existing threads and can't figure out where I'm doing it wrong...



      I'm trying to get the average of two values and then round the average to the nearest TEN (10).



      My expression is:



      =ROUND((Fields!Cyl1Stress.Value + Fields!Cyl2Stress.Value) / 2, -1)


      The above returns an error.



      Rounding to the nearest TENTH works fine, but as soon as I change the 1 to -1, I get the error.



      Where Cyl1Stress.Value = 7600 and Cyl2Stress.Value = 7490.



      =ROUND((Fields!Cyl1Stress.Value + Fields!Cyl2Stress.Value) / 2, **1**) 


      The above code returns 7545.



      But I need the result to be 7550, so I change my formula to:



      =ROUND((Fields!Cyl1Stress.Value + Fields!Cyl2Stress.Value) / 2, **-1**). 


      This one returns an error.



      Can't figure out why this isn't working!



      Text Box Properties are Numeric, 0 decimal places.










      share|improve this question















      I've searched the existing threads and can't figure out where I'm doing it wrong...



      I'm trying to get the average of two values and then round the average to the nearest TEN (10).



      My expression is:



      =ROUND((Fields!Cyl1Stress.Value + Fields!Cyl2Stress.Value) / 2, -1)


      The above returns an error.



      Rounding to the nearest TENTH works fine, but as soon as I change the 1 to -1, I get the error.



      Where Cyl1Stress.Value = 7600 and Cyl2Stress.Value = 7490.



      =ROUND((Fields!Cyl1Stress.Value + Fields!Cyl2Stress.Value) / 2, **1**) 


      The above code returns 7545.



      But I need the result to be 7550, so I change my formula to:



      =ROUND((Fields!Cyl1Stress.Value + Fields!Cyl2Stress.Value) / 2, **-1**). 


      This one returns an error.



      Can't figure out why this isn't working!



      Text Box Properties are Numeric, 0 decimal places.







      reporting-services expression rounding






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 at 7:42









      Serhiy

      2,97422857




      2,97422857










      asked Nov 9 at 18:52









      TracyJ

      1




      1






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote













          I don't believe you can use a negative value for the Digits argument of Round. The documentation indicates:




          The number of fractional digits in the return value. For Decimal values, it can range from 0 to 28. For Double values, it can range from 0 to 15.




          You can accomplish what you are looking to do by dividing the value by 10, round to the nearest whole number, and then multiply by 10. Also note that if you want a value ending in 5 to round up to the next 10, you will need to add a third argument to Round to indicate this, otherwise I believe the default behavior rounds to the nearest even number. This would cause your example to round to 7540 instead of 7550.



          This expression should be what you are looking for:



          =ROUND(((Fields!Cyl1Stress.Value + Fields!Cyl2Stress.Value) / 2) / 10, 0, MidpointRounding.AwayFromZero) * 10


          For your example values, this turns 7545 into 754.5, rounds to the nearest whole number and rounds it away from zero instead of to the nearest even number (755), then multiplies by 10 (7550).






          share|improve this answer




















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53231728%2ferror-when-rounding-to-nearest-10-in-ssrs-expression%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote













            I don't believe you can use a negative value for the Digits argument of Round. The documentation indicates:




            The number of fractional digits in the return value. For Decimal values, it can range from 0 to 28. For Double values, it can range from 0 to 15.




            You can accomplish what you are looking to do by dividing the value by 10, round to the nearest whole number, and then multiply by 10. Also note that if you want a value ending in 5 to round up to the next 10, you will need to add a third argument to Round to indicate this, otherwise I believe the default behavior rounds to the nearest even number. This would cause your example to round to 7540 instead of 7550.



            This expression should be what you are looking for:



            =ROUND(((Fields!Cyl1Stress.Value + Fields!Cyl2Stress.Value) / 2) / 10, 0, MidpointRounding.AwayFromZero) * 10


            For your example values, this turns 7545 into 754.5, rounds to the nearest whole number and rounds it away from zero instead of to the nearest even number (755), then multiplies by 10 (7550).






            share|improve this answer
























              up vote
              2
              down vote













              I don't believe you can use a negative value for the Digits argument of Round. The documentation indicates:




              The number of fractional digits in the return value. For Decimal values, it can range from 0 to 28. For Double values, it can range from 0 to 15.




              You can accomplish what you are looking to do by dividing the value by 10, round to the nearest whole number, and then multiply by 10. Also note that if you want a value ending in 5 to round up to the next 10, you will need to add a third argument to Round to indicate this, otherwise I believe the default behavior rounds to the nearest even number. This would cause your example to round to 7540 instead of 7550.



              This expression should be what you are looking for:



              =ROUND(((Fields!Cyl1Stress.Value + Fields!Cyl2Stress.Value) / 2) / 10, 0, MidpointRounding.AwayFromZero) * 10


              For your example values, this turns 7545 into 754.5, rounds to the nearest whole number and rounds it away from zero instead of to the nearest even number (755), then multiplies by 10 (7550).






              share|improve this answer






















                up vote
                2
                down vote










                up vote
                2
                down vote









                I don't believe you can use a negative value for the Digits argument of Round. The documentation indicates:




                The number of fractional digits in the return value. For Decimal values, it can range from 0 to 28. For Double values, it can range from 0 to 15.




                You can accomplish what you are looking to do by dividing the value by 10, round to the nearest whole number, and then multiply by 10. Also note that if you want a value ending in 5 to round up to the next 10, you will need to add a third argument to Round to indicate this, otherwise I believe the default behavior rounds to the nearest even number. This would cause your example to round to 7540 instead of 7550.



                This expression should be what you are looking for:



                =ROUND(((Fields!Cyl1Stress.Value + Fields!Cyl2Stress.Value) / 2) / 10, 0, MidpointRounding.AwayFromZero) * 10


                For your example values, this turns 7545 into 754.5, rounds to the nearest whole number and rounds it away from zero instead of to the nearest even number (755), then multiplies by 10 (7550).






                share|improve this answer












                I don't believe you can use a negative value for the Digits argument of Round. The documentation indicates:




                The number of fractional digits in the return value. For Decimal values, it can range from 0 to 28. For Double values, it can range from 0 to 15.




                You can accomplish what you are looking to do by dividing the value by 10, round to the nearest whole number, and then multiply by 10. Also note that if you want a value ending in 5 to round up to the next 10, you will need to add a third argument to Round to indicate this, otherwise I believe the default behavior rounds to the nearest even number. This would cause your example to round to 7540 instead of 7550.



                This expression should be what you are looking for:



                =ROUND(((Fields!Cyl1Stress.Value + Fields!Cyl2Stress.Value) / 2) / 10, 0, MidpointRounding.AwayFromZero) * 10


                For your example values, this turns 7545 into 754.5, rounds to the nearest whole number and rounds it away from zero instead of to the nearest even number (755), then multiplies by 10 (7550).







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 9 at 19:21









                C Black

                738310




                738310



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53231728%2ferror-when-rounding-to-nearest-10-in-ssrs-expression%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

                    Syphilis

                    Darth Vader #20