# Is it possible to develop a cron-triggered delta calculation with Analytics Builder?

**URL:** <https://community.cumulocity.com/t/is-it-possible-to-develop-a-cron-triggered-delta-calculation-with-analytics-builder/309>\
**Category:** Forum\
**Tags:** Streaming-Analytics-Apama, cumulocity\
**Created:** [April 29, 2022, 8:53am UTC](https://community.cumulocity.com/t/is-it-possible-to-develop-a-cron-triggered-delta-calculation-with-analytics-builder/309 "2022-04-29T08:53:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![OliverT](https://avatars.discourse-cdn.com/v4/letter/o/a183cd/32.png) [@OliverT](https://community.cumulocity.com/u/OliverT)\
**Post date:** [April 29, 2022, 8:53am UTC](https://community.cumulocity.com/t/is-it-possible-to-develop-a-cron-triggered-delta-calculation-with-analytics-builder/309/1 "2022-04-29T08:53:22Z")

</div>

#### What product/components do you use and which version/fix level?

Cumulocity 1011.0.19

#### Are you using a free trial or a product with a customer license?

customer license

#### What are trying to achieve? Please describe in detail.

A total consumption per hour is to be determined from an infrequently supplied measured value for the current power consumption.

Building a total consumption meter since the start of the model is possible with the standard blocks. The difficulty is to determine the total consumption for an hourly interval. I wanted to use cron for this, but have not found a solution for transferring a value to the delta calculation just once every hour.

Is there a standard block or a combination of blocks to achieve this?

Here is my model with the missing block in the middle …  
[hourly power consumption.zip](https://community.cumulocity.com/uploads/short-url/wBTuWTNe1Xiamlu1OxzZnovcq4k.zip) (1.5 KB)

Best Regards,  
Oliver

---

<div class="post-metadata">

**Author:** ![Gyanendra\_Singh\_Bais](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/gyanendra_singh_bais/32/31950_2.png) [@Gyanendra\_Singh\_Bais](https://community.cumulocity.com/u/Gyanendra_Singh_Bais)\
**Post date:** [April 29, 2022, 9:49am UTC](https://community.cumulocity.com/t/is-it-possible-to-develop-a-cron-triggered-delta-calculation-with-analytics-builder/309/2 "2022-04-29T09:49:22Z")

</div>

Hi Oliver,

You can use a Gate block to pass the integral value to the Delta block only when the Cron block triggers. To do this, pass the integral value to the Gate block and connect the output of the Gate block to the Delta block. Also connect the output of the Cron block to the **Enable** input port of the Gate block. This cause Gate block to be enabled only when Cron block is triggered and it lets the value through to the Delta block. Because output of the Cron block is a pulse, Gate block will be disable rest of the time. See the example screenshot:

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/cumulocity/original/3X/8/6/8628702b0cfc0f15df43fc7b4db45654bab0b84e.png)

Thanks,  
Gyan

---

<div class="post-metadata">

**Author:** ![OliverT](https://avatars.discourse-cdn.com/v4/letter/o/a183cd/32.png) [@OliverT](https://community.cumulocity.com/u/OliverT)\
**Post date:** [April 29, 2022, 10:51am UTC](https://community.cumulocity.com/t/is-it-possible-to-develop-a-cron-triggered-delta-calculation-with-analytics-builder/309/3 "2022-04-29T10:51:48Z")

</div>

Oh that sounds easy. I was fooled by the documentation. It says at the output for the Gate block: “Same value as the input value if the gate is open and enabled. Otherwise, the value set by the zero value parameter.” [Gate documentation](https://documentation.softwareag.com/apama/Analytics_Builder/pab10-11-0/apama-pab-webhelp/index.html#page/apamaanalyticsbuilder-webhelp%2Fre_AnaBui_block_reference_Flow_Manipulation_Gate.html%23)

And Zero would not work so good for the Delta block.

This is exactly what I was looking for! Thank you!

---

<div class="post-metadata">

**Author:** ![Gyanendra\_Singh\_Bais](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/gyanendra_singh_bais/32/31950_2.png) [@Gyanendra\_Singh\_Bais](https://community.cumulocity.com/u/Gyanendra_Singh_Bais)\
**Post date:** [April 29, 2022, 11:15am UTC](https://community.cumulocity.com/t/is-it-possible-to-develop-a-cron-triggered-delta-calculation-with-analytics-builder/309/4 "2022-04-29T11:15:31Z")

</div>

The Null Value parameter is optional. If it is not specified then no value will be outputted if Gate is disabled or closed.

Thanks,  
Gyan

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/system/32/31990_2.png) [@system](https://community.cumulocity.com/u/system)\
**Post date:** [July 28, 2022, 11:15am UTC](https://community.cumulocity.com/t/is-it-possible-to-develop-a-cron-triggered-delta-calculation-with-analytics-builder/309/5 "2022-07-28T11:15:46Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
