Hello everyone, I have a question about 2 PQL formulas.😅
In this case, I need a conditional that checks if it is the last record of the ID, if so, make a formula that takes the timestamp of this record and does the DAYS_BETWEEN between this date and today's date.
If the timestamp of that record is not the last one, use the formula below:
AVG( DAYS_BETWEEN ("table_activities"."TIMESTAMPLE",
LAG (
"table_activities"."TIMESTAMPLE"
, ORDER BY ("table_activities".."TIMESTAMPLE" DESC)
, PARTITION BY ("table_activities",."PROCESS_CELONIS", "table_activities"."ID")
)))
I think it would be something like this:
CASE WHEN PU_LAST ("tabela_atividades"."TIMESTAMPLE") = "tabela_atividades"."TIMESTAMPLE" --this for each id
THEN
DAYS_BETWEEN (AVG( DAYS_BETWEEN ("table_activities"."TIMESTAMPLE", TODAY)
ELSE
AVG( DAYS_BETWEEN ("table_activities"."TIMESTAMPLE",
LAG (
"table_activities"."TIMESTAMPLE"
, ORDER BY ("table_activities"."TIMESTAMPLE" DESC)
, PARTITION BY ("table_activities"."PROCESS_CELONIS", "tabela_atividades"."ID")
)))
Thanks for everyone's help! 😄