Skip to main content

So I basically need the maximum of:

 

PU_COUNT ( DOMAIN_TABLE ( "CEL_ACTIVITIES_SF"."CASE_ID","CEL_ACTIVITIES_SF"."USER_ID"), FILTER_TO_NULL ( "CEL_ACTIVITIES_SF"."USER_ID" ))

 

per case

 

A little bit of a hack but this seems to work utilising a combination of PU_FIRST and 2 x INDEX_ORDER (1 to count the incidence of case id and user name allowing you to then sort by this value and the second to order the count of the user activities.

 

PU_FIRST(

 "CASES"

 , "CEL_ACTIVITIES_SF"."USER_ID"

 ,ORDER BY INDEX_ORDER(

  "CEL_ACTIVITIES_SF"."USER_ID"

 ,ORDER BY (INDEX_ORDER(

  "CEL_ACTIVITIES_SF"."USER_ID"

 ,PARTITION BY ( "CEL_ACTIVITIES_SF"."CASE_ID", "CEL_ACTIVITIES_SF"."USER_ID")) DESC)

,PARTITION BY ( "CEL_ACTIVITIES_SF"."CASE_ID", "CEL_ACTIVITIES_SF"."USER_ID")

) DESC)


Thanks, yes this also seems to work.

 

PU_FIRST ( "CEL_CASETABLE_SF",

"CEL_ACTIVITIES_SF"."USER_ID",

ORDER BY INDEX_ORDER (  "CEL_ACTIVITIES_SF"."USER_ID"

, ORDER BY(PU_COUNT ( DOMAIN_TABLE ( "CEL_ACTIVITIES_SF"."CASE_ID","CEL_ACTIVITIES_SF"."USER_ID"), FILTER_TO_NULL ( "CEL_ACTIVITIES_SF"."USER_ID" ))DESC)

, PARTITION BY("CEL_ACTIVITIES_SF"."CASE_ID")

 )

)


Reply