Skip to main content
Question

OCPM Order events of the same type

  • May 6, 2026
  • 2 replies
  • 457 views

stefania
Level 2
Forum|alt.badge.img

I created a ‘Status change’ event in OCPM and I can’t establish an order for the events that have the same timestamp. The script looks like this (I simplified it to be easier to understand):

SELECT DISTINCT 
'MeldungGeneralEvent_' || meldung_objects.QMNUM || JCDS.STAT || JCDS.UDATE || JCDS.UTIME AS "ID",
'Meldung_' || meldung_objects.QMNUM AS "Meldung",
'Meldung Status Changed' AS ActivityName,
COALESCE(SS.TXT04, US.TXT04) AS ActivityStatus,
CAST(JCDS.UDATE AS DATE) + CAST(JCDS.UTIME AS TIME) AS "Time",
CASE
WHEN COALESCE(SS.TXT04, US.TXT04) LIKE '%EGPR%' THEN 33
WHEN COALESCE(SS.TXT04, US.TXT04) LIKE '%MMAB%' THEN 34
ELSE 32
END AS Sorting,
FROM meldung_objects

To give an example, I select only the activities for Meldung number “748291035”:

The way I want my activities to be ordered is like this:

  • Time
  • Sorting
  • Alphabetical order for ActivityStatus

So the order to be: MOFN, UGPR, MAUF, MIAR, EGPR, MMAB

First, I tried to use the Sorting column in the Knowledge Model, where I defined my Event log.

But this Sorting can not be used for ‘Status Change’ events, that need to be relabeled.

Therefore, in my script defined in Tranformations in ‘Object and Events’, I added an order by clause, at the end of the select:

SELECT DISTINCT 
'MeldungGeneralEvent_' || meldung_objects.QMNUM || JCDS.STAT || JCDS.UDATE || JCDS.UTIME AS "ID",
'Meldung_' || meldung_objects.QMNUM AS "Meldung",
'Meldung Status Changed' AS ActivityName,
COALESCE(SS.TXT04, US.TXT04) AS ActivityStatus,
CAST(JCDS.UDATE AS DATE) + CAST(JCDS.UTIME AS TIME) AS "Time",
CASE
WHEN COALESCE(SS.TXT04, US.TXT04) LIKE '%EGPR%' THEN 33
WHEN COALESCE(SS.TXT04, US.TXT04) LIKE '%MMAB%' THEN 34
ELSE 32
END AS Sorting,
FROM meldung_objects
ORDER BY
Meldung,
"Time",
Sorting,
ActivityStatus

I notice that after the transformation is ran in the Data Integration, my table is not ordered, so I think ORDER BY does not work in here.

So the question is, how can I order the activities?

 

2 replies

Hi Stefania,

The Sorting column is the right mechanism — but it only works if it is explicitly mapped as the activity table’s sorting column in the data model / event log configuration. If it is not mapped, Celonis can fall back to undefined ordering for same-timestamp events, and in practice that often looks alphabetical by activity name.

So for your target order, you should assign numeric sorting values, for example:

- MOFN → 1
- UGPR → 2
- MAUF → 3
- MIAR → 4
- EGPR → 5
- MMAB → 6

 

and then make sure that column is configured as the activity table’s Sorting field. Lower value = earlier activity

What to check:
1. Open the activity table / event log configuration.
2. Verify the columns mapped are at least:
   - Case ID
   - Activity
   - Event Time
   - Sorting
3. Set your numeric order column as Sorting.
4. Reload the data model and refresh the analysis.


gagan1
Member Spotlight
Forum|alt.badge.img+5
  • Member Spotlight
  • June 22, 2026

If the sorting column in the UI is still causing issues, the easiest fix is to add fractional seconds directly inside your SQL transformation.

Since you already have your sorting logic (32, 33, 34), you can ad a tiny time offset to your timestamp based on that rank. This forces Celonis to order them correctly without relying on the UI settings.

For example, you can change your timestamp calculation to this ->

CAST(JCDS.UDATE AS DATE) + CAST(JCDS.UTIME AS TIME) + (
CASE
WHEN COALESCE(SS.TXT04, US.TXT04) LIKE '%EGPR%' THEN INTERVAL '0.001' SECOND
WHEN COALESCE(SS.TXT04, US.TXT04) LIKE '%MMAB%' THEN INTERVAL '0.002' SECOND
ELSE INTERVAL '0' SECOND
END
)

Adding a millisecond offset ensures the events display in the correct order in your Process Explorer, without changing the actual dates in your charts. 

it may help