Toggle a class for an alert based on 3 conditions

Hello,
I’ve been searching throughout the forum and documentation, including reports such as this one, and I am not clear if what I want is feasible:
I have an alert, and I want to change its type (danger, warning, success), based on a condition picked up on page loading from an expression. I have tried toggling class and assigning dynamic attributes, but I must be doing something wrong.
Base code is:

<div class="alert alert-danger" role="alert" id="alert_impact"></div>
Community Page
Last updated: