Seeq Team Allison Buenemann Posted July 22, 2019 Seeq Team Share Posted July 22, 2019 FAQ: For reporting purposes, I want to calculate statistics based on the current period to date and display that next to the periods immediately preceding it. This is easy to do using the custom date range tool in Organizer Topic (Creating a Periodic Condition and the grabbing the capsule closest to or offset by 1 from the end). Is there a way to create these same date ranges relevant to the current time in Seeq Workbench? Solution: We can create identical conditions in Seeq Workbench by following the methods below. The first method defines how to create conditions for current and previous conditions for years, days, weeks, shifts. The second method includes an extra step that is necessary for current and previous months and quarters since the exact duration of these periods can vary based on the number of days each month. Method 1 - when the length of time in each period is definitive (e.g. year, week, day, shift). This example shows how to create conditions for "Current Week" and "Previous Week" 1. Create a Periodic Condition for "Weekly" using the Periodic Condition tool. 2. Create a Condition around the current time ("Now") using Formula --> condition(1min, capsule(now() - 1min, now())) 3. Use the Composite Condition tool to create a condition for "Current Week" when the Periodic Condition "Weekly" touches the tiny capsule at "Now". 4. Use Formula to create a condition for the "Previous Week" --> $currentWeek.beforeStart(7d) Method 2 - when the length of time in each period is variable (e.g. month, quarter). This example creates a condition for "Current Month" and "Previous Month" 1. Create a Periodic Condition for "Monthly" using the Periodic Condition tool. 2. Create a Condition around the current time ("Now") using Formula --> condition(1min, capsule(now() - 1min, now())) 3. Use the Composite Condition tool to create a condition for "Current Month" when the Periodic Condition "Monthly" touches the tiny capsule at "Now". 4. Use Formula to create a Condition for the last day of the last period (in this case "Last Day of the Last Month") $currentMonth.beforeStart(1d) 5. Use the Composite Condition tool to create a condition for the "Previous Month" when the Periodic Condition "Monthly" touches the "Last Day of Last Month". 2 Link to comment Share on other sites More sharing options...
Peter Vanney Posted February 28, 2020 Share Posted February 28, 2020 Thanks for the post, Allison! I wanted to share how I took what you did and made it into rolling a "year to date" (YTD) metric, and other comparable metrics. I work in hydroelectric generation, so my utility operates a few dams. One of the things we want to track is how close our upstream water level (headwater) gets to our buffered operating limits (in this case I'm looking at buffered lower limit dips). Here's a screenshot of the example scorecard metrics I created: And here are the dependency trees: Here's how I did it: So, starting from the deepest part of the trees: ‘Yearly 1’ is common to all three. It is standard Periodic Condition for Yearly capsules. ‘Now Condition’ follows the forum post. Make this formula: condition(1min, capsule((now()-1min), now())) ‘Year Ago Now’ is based on the ‘Now Condition’ but you subtract off another year. Make this formula: condition(1min, capsule((now() - 1min - 1year), (now() - 1year))) ‘Current Year’ is a composite condition of ‘Yearly 1’ and ‘Now Condition’ using “Touches” ‘Last Year’ is a composite condition of ‘Yearly 1’ and ‘Year Ago Now’ using “Touches” ‘Rolling Year Condition’ is a formula. condition(1year, capsule((now()-1year), now())) ‘Year to Date’ is a composite condition of ‘Current Year’ and ‘Rolling Year Condition’ using “Intersection” (i.e. when is it both the current year and happening within the last year.) ‘Last Year to Date’ is a composite condition ‘Last Year’ and ‘Rolling Year Condition’ using “A minus B” (i.e. when is it last year but not within the last rolling year.) Then you can create your usual value based conditions. I used RI Headwater less than 610. Then you create your metrics! Here’s the screenshot of the Year to Date metric. To get Last YTD, you simply change the condition at the bottom to ‘Last Year to Date.’ The metrics refresh when you refresh the screen! 2 Link to comment Share on other sites More sharing options...
Seeq Team Allison Buenemann Posted February 28, 2020 Author Seeq Team Share Posted February 28, 2020 This is an awesome solution Peter! Link to comment Share on other sites More sharing options...
Ielish Goble Posted December 16, 2021 Share Posted December 16, 2021 (edited) Hi! I'm hoping to use this in a dashboard that displays this month to date as well as the previous 3 months data. Is it possible to use this method with a splice function so that this is all displayed on one signal/metric? Edited December 16, 2021 by Ielish Goble Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now