Allison Buenemann Posted July 22, 2019 Share Posted July 22, 2019 (edited) For reporting purposes, I want to calculate statistics based on the most recent period(capsule) and display that along with the periods immediately preceding it. This can be done in Organizer using the custom date range by creating a Periodic Condition and selecting the capsule closest to or offset by one from the end. The same date ranges or capsules relative to now can be created in Seeq Workbench as well. Organizer: Workbench: We create the same condition as the above Organizer in 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". Content Verified DEC2023 Edited December 1, 2023 by Synjen Marrocco Cleaning up for 2023 Swarm 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...
Allison Buenemann Posted February 28, 2020 Author 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...
Synjen Marrocco Posted December 1, 2023 Share Posted December 1, 2023 Multiple conditions that contain current, previous, or other specific timeframes can be combined into one condition using the combineWith() function. The above method may not be required if you would like to have your aggregated signal calculated across every capsule within a condition (i.e. every week in a weekly condition). combineWith($current_week, $previous_week, $week_N) 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