WINDOW_AVG (or alternatives)
Hi all, I calculate the average cycle time from PO Item creation to Record Goods Receipt per material with the following query:
PU_AVG (
DOMAIN_TABLE ( "EKPO"."MATNR" ) ,
DAYS_BETWEEN (
PU_FIRST (
"EKPO" ,
"_CEL_P2P_ACTIVITIES"."EVENTTIME" ,
"_CEL_P2P_ACTIVITIES"."ACTIVITY_EN" = 'Create Purchase Order Item'
) ,
PU_FIRST (
"EKPO" ,
"_CEL_P2P_ACTIVITIES"."EVENTTIME" ,
"_CEL_P2P_ACTIVITIES"."ACTIVITY_EN" = 'Record Goods Receipt'
)
)
)
Now, I want to consider only the latest 10 PO items into the calculation based on the creation date. How can I do that? I tried the WINDOW_AVG function, but it does not work:
WINDOW_AVG( <above query>, 0, 10, ORDER BY (
PU_FIRST (
"EKPO" ,
"_CEL_P2P_ACTIVITIES"."EVENTTIME" ,
"_CEL_P2P_ACTIVITIES"."ACTIVITY_EN" = 'Create Purchase Order Item'
) DESC
)
, PARTITION BY ( "EKPO"."MATNR"))
This query shows the same results as the one above and it shows wrong values.