Hi James,
This is absolutely possible using 'if' statements in calculated metrics (we do this all the time).
Imagine the scenario where you wanted to create an alert when 'orders' are less than or equal to 1000.
Method:
- Create a 'hit' level segment called 'non-core hours'
- 'hour of day' is greater than or equal to '1:00am'
AND
- 'hour of day is less than or equal to '6:00am'
- Create a calculated metric called 'Core hours orders'
- using the 'if' function
- within 'logic_test' place your 'non-core hours' segment with the 'occurences' metric nested inside it
- within 'value_if_true' add a 'Static Number' with a value of '1001' (Note: this needs to be any value which would not trigger an alert, in this case greater than 1000)
- within 'value_if_false' add the 'Orders' metric
- Create an hourly granularity Alert called 'core hours order alert' where:
- the calculated metric 'core hours orders' is below or equals '1000'
During the night 1am to 6:59am as long as you get at least 1 hit in each hour, the value will always be 1001 so the alert never triggers. During the rest of the day it will tigger if orders is equal or below 1000.
NOTE: this method also works for the 'anomaly exceeds' alerting option. If you set a Static Value at the same time every night anomaly detection does not see it as an anomaly (because it is the same every night).
Hope this helps,
Andrew