Skip to main content
Solved

COUNT_TABLE with CASE WHEN

  • April 24, 2025
  • 5 replies
  • 99 views

fabian.altendorfer
Level 3
Forum|alt.badge.img

Hi,

is it possible to use a COUNT_TABLE together with CASE WHEN to form a KPI? Below Query works for a simple COUNT with “TABLE”.”COLUMN” in THEN, but doesn’t work for COUNT_TABLE.

 

COUNT_TABLE(CASE_WHEN(PROCESS EQUALS XY OR PROCESS EQUALS XZ) THEN "CASES" END)

 

Thanks!

Best answer by Sverre Klein

Hi ​@fabian.altendorfer,

You can use SUM and CASE WHEN together to achieve this.

 

SUM(CASE WHEN PROCESS EQUALS XY THEN 1 ELSE 0 END)

This allows you to count the amount of cases that satisfy your case when statement.

5 replies

Sverre Klein
Level 10
Forum|alt.badge.img+14
  • Level 10
  • 204 replies
  • Answer
  • April 24, 2025

Hi ​@fabian.altendorfer,

You can use SUM and CASE WHEN together to achieve this.

 

SUM(CASE WHEN PROCESS EQUALS XY THEN 1 ELSE 0 END)

This allows you to count the amount of cases that satisfy your case when statement.


fabian.altendorfer
Level 3
Forum|alt.badge.img

Thanks Severre, how to add the data source in this Query then?


Sverre Klein
Level 10
Forum|alt.badge.img+14
  • Level 10
  • 204 replies
  • April 24, 2025

Do you mean for the PROCESS EQUALS function? It takes the activity table’s activity column automatically. Or do you mean something else?

https://docs.celonis.com/en/process-equals.html

Let me know what you want to achieve.


fabian.altendorfer
Level 3
Forum|alt.badge.img

I wasn’t aware that PROCESS EQUALS automatically uses the activity column. With that in mind, the provided query provides what I was looking for, thanks a lot!


Sverre Klein
Level 10
Forum|alt.badge.img+14
  • Level 10
  • 204 replies
  • April 24, 2025

Glad it helped Fabian!

Consider marking my comment as the solution, so that it also may help others in the future! Good luck and have fun mining :)