How to count sales order (VBAK) that under goes activities?

Hello Everyone,

I hope you all doing good :slight_smile:

I would like to see how many orders that are going through Credit Check. Normally, the credit check was executed on the Header level, which means we do not care about position lines. But in the Celonis the activity is defined from Order item not from the order header level.

In order to see the total number of orders that are going through credit check , I have implemented PQL code

As

COUNT((CASE WHEN “_CEL_O2C_ACTIVITIES”.“ACTIVITY_EN” IN (‘Deny Credit Check’,‘Approve Credit Check’)

THEN " VBAK".“VBELN” ELSE NULL END))/COUNT_TABLE(“VBAK”)

But still it counts the activity.

Do you have any idea, how to count only sales orders for an activity by using any other function?

Thanks in Advance

With regards
Rahul

Hi Rahul,

In your case I would recommend adding a DISTINCT and give back the two primary keys of VBAK, which means every Header will only be counted once, no matter how many Credit Checks happened. It should look something like this:

COUNT(DISTINCT CASE WHEN
“_CEL_O2C_ACTIVITIES”.“ACTIVITY_EN” IN (‘Deny Credit Check’,‘Approve Credit Check’)

THEN “VBAK”.“MANDT” || “VBAK”.“VBELN” ELSE NULL END)
/
COUNT_TABLE(“VBAK”)

Best Regards,

Bene

Hi Bene,

Thanks for the help! It works now :slight_smile:

With Regards
Rahul