Help with Alerting on port utilization below avergae

I’d like to generate an alert if a ports usage falls below the average port usage for greater than X amount of time.

I can’t tell if this is functionally doable creating a macro for something like:
ports.ifInOctets_rate < ports.ifInOctets_previous

Any help would be appreciated.

-J