Count alarma active

Hi. I need to add the number of times that a larm was active during a period of time of work, that is if the alarm was activated 10 times in the day, I want to count those times and write that value in a new tag.