How-To Guides
Analytics Guides
Use the Rounding Function
12min
you can use the rounding processor to round off the collected data to the nearest decimal place understanding rounding methods you have the following rounding options roundnearest this method returns a rounded value based on the number of decimal digits configured for instance, if you set two decimal digits and the value is 1 5677, the rounded value will be 1 57 roundup a method that rounds up the value to the specified number of decimal digits for example, if you specify two decimal digits and the value is 1 3221, the rounded up value would be 1 33 rounddown a method that rounds down the value to the specified number of decimal digits for example, if you specify two decimal digits and the value is 1 3221, the rounded value is 1 32 roundeven this method rounds to the nearest even integer in cases of rounding ties (when both integers are equidistant, e g 1 5) in any other case, it acts as a round nearest function if the value is 1 3221 and 1 5, the rounded even value is 1 and 2, respectively, as the nearest even integer user scenario review the following scenario for rounding off the tag values then, you will simulate data from a plc and make the following rounding conversions some of your manufacturing sites with multiple plcs collect data with high precision you can round off the collected data for easier aggregation, computation, visualization, comprehension, and communication step 1 add a device follow the steps to connect a device docid\ nm1lqfefya dsiffitity and configure the following parameters device type simulator driver name generator enable alias topics select the checkbox step 2 add tags after connecting the device, add the following tags see add tags docid\ h5heqicxrcy3nch9kbg9i to learn more each tag will represent one of the round function options noted above tag 1 roundnearest name select s random value generator value type select float64 polling interval enter 5 tag name enter roundnearest min value enter 1 523 max value enter 1 523 tag 2 roundup name select s random value generator value type select float64 polling interval enter 5 tag name enter roundup min value enter 1 523 max value enter 1 523 tag 3 rounddown name select s random value generator value type select float64 polling interval enter 5 tag name enter rounddown min value enter 1 523 max value enter 1 523 tag 4 roundeven name select s random value generator value type select float64 polling interval enter 5 tag name enter roundeven min value enter 1 523 max value enter 1 523 step 3 create analytics flows you can now create the analytics flows using data from the device and tags you previously created to create an analytics flow with the rounding function navigate to analytics on the analytics canvas, click add processor the create a processor dialog displays select datahub subscribe in the topic field, click the search icon, select the device you previously created, and then select the alias topic for the roundnearest tag click save click add processor again and select rounding the following information describes this function for digits , enter the number of digits for which you would like to round entering 0 ignores all floating point values and gives the integer value for method , select roundnearest click save connect the two processors, select events , and enter a definition of roundnearest for the connection repeat steps 2 8 for the round up tag and configure the following in the datahub subscribe processor, select the alias topic for the roundup tag in the method dropdown , select roundup when you connect the two processors, select events and enter a definition of roundup for the connection repeat steps 2 8 for the round down tag and configure the following in the datahub subscribe processor, select the alias topic for the rounddown tag in the method dropdown , select rounddown when you connect the two processors, select events and enter a definition of rounddown for the connection repeat steps 2 8 for the round even tag and configure the following in the datahub subscribe processor, select the alias topic for the roundeven tag in the method dropdown , select roundeven when you connect the two processors, select events and enter a definition of roundeven for the connection on the analytics canvas, click save the configured analytics flows should look like the following step 4 view rounded data you can view data on the analytics canvas by clicking the view icon in each rounding processor round data for roundnearest tag the roundnearest method returns 2 as the answer when 1 523 is used as an input value round data for roundup tag the roundup method returns 1 53 as the answer when 1 523 is used as an input value round data for rounddown tag the rounddown method returns 1 52 as the answer when 1 523 is used as an input value round data for roundeven tag the roundeven method returns 2 as the answer when 1 523 is used as an input value