Jump to content

Aggregate Startkey() & middlekey() Formula


Ali

Recommended Posts

Hello, 

I'm using the aggregate formula and I'm having hard time understanding Startkey() & middlekey().  Endkey() is very clear. 

I used $s.aggregate(average(),periods(1year,1day),Endkey()) to calculate the yearly rolling avg and time stamp it at the end of each day. 

I did the same thing for 6 month capsules $s.aggregate(average(),periods(1year,6month),Endkey()) and the end value of both data is equal. 

When I use middlekey(): $s.aggregate(average(),periods(1year,6month),middlekey()) , I thought Seeq would calculate the middle value of the capsule meaning  the last bar value on the graph below would calculate the average of 9/30/2018- 9/30/2019. 

And for the startkey(), I thought the last bar value represents the beginning of the capsule rolling back 365 days.  from 6/30/2018- 6/30/2019. 

Please advice. Thanks

image.thumb.png.717fef25ee64399127aa243cd3f9abde.png

                                                                

 

Link to comment
Share on other sites

Hi Ali,

startKey(), middleKey() and endKey() provide just the timestamp where Seeq will put the calculated value. In your example using periods(1year,6month) Seeq will always calculate the average for one year starting from January (e.g. 01/01/2018 - 01/01/2019) and the average starting from July (e.g. 07/01/2018 - 07/01/2019).

For the period 01/01/2018 - 01/01/2019 using

- startKey() will put the value to 01/01/2018
- middleKey() will put the value to 07/01/2018
- endKey() will put the value to 01/01/2019

The marked columns in the following Analysis all have the same value for the period of last year :

 

image.thumb.png.bf74028e0adbdaf2e8f7acf1c28a8b82.png

Hope this helps.

Regards,

Thorsten

 

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...