Skip to main content

In our Datamodel every activity can additionally get multiple (0..n) labels. Due to the nature of 0..n relations this cannot be done via activity attributes as we don't know the nessessary amount of columns in forehand. That's why these labels (strings) are stored in a seperate table. Foreign Key is the unique activity ID.

 

I know how to filter/flag cases with the MATCH_PROCESS function. Here we use the nodenames or another string column, but the column is always part of the activity table.

 

Now I want to do something like:

Give me all cases where an activity with the associated label "Greeting" is directily followed by an activity with the associated label "Error".

 

Is it possible to filter cases based on the labels that are stored in a seperate table?

 

Hi Florian,

 

This is possible by first pulling the label to the activity table. Then, you can use MATCH_PROCESS or PROCESS EQUALS to filter.

 

In order to pull the label to the activity table, you can use PU functions. I think the most difficult part to take care of is that potentially, an activity can have both "Greeting" and "Error" labels at the same time. If that cannot happen, the query could also be simplified.

 

But to cover everything, I would suggest to use PU_STRING_AGG to aggregate the labels to the activity table:

 

COALESCE(PU_STRING_AGG("Activities", "Labels"."Label", "Labels"."Label" IN ('Greeting', 'Error')), '')

 

This returns a string column for the activity table containing 'Greeting', 'Error' or both ( e.g. 'Greeting, Error' ). The coalesce makes sure that the result cannot be NULL, which is required because NULL values will be skipped by PROCESS EQUALS, and therefore the "directly follows" requirement could not be satisified.

 

With this you can now write a PROCESS EQUALS condition, which you can use inside a CASE WHEN or FILTER:

 

PROCESS ON COALESCE(PU_STRING_AGG("Activities", "Labels"."Label", "Labels"."Label" IN ('Greeting', 'Error')), '') EQUALS LIKE '%Greeting%' TO LIKE '%Error%'

 

Hope this works, let me know if there are any questions!

 

Cheers

David

 

 

 

 

 

 

 

 

 

 

 

 


Reply