Count alarms/different alarms in a PI TAG over a certain time

I have a PI-tag that collect all alarms of PLC/WinCC and need to do some analytics on it.

 

Tag value looks like this and has a lot of changed values:

 

@LOCALMACHINE::WAZI\ALGEMEEN_WAZI/SMS/BIOLOGIE|Process message|Process message|15007|64|-BIO- aktieve PH sonde < PH laag parameter||ENABLED|NOT ACTIVE|ACKED|NOACKREQD|192|WAZI|ALGEMEEN_WAZI/SMS/BIOLOGIE|Process message class|Process message|1||809100

 

I was already able to collect the needed values/statuses from the big string into PI AF attributes.

 

What I want to do now is to count how many alarms we had over an certain time. Made a new attribute(boolean) that indicates if it is a new alarm (active and not Acknowledged)

And then use this expression NumOfChanges('NewAlarm','*-24h','*')/2

But think there must be a better way?

 

But the biggest problem is that I want a count of the different alarms.

For example we have 6 alarms in the last hour 3x alarm1 2x alarm2 en 1x alarm3

Don't know how to start with this.

Do I need to create an array and then do some calculation on it? Or is there an other way?

Anyone experience with this?