Ranking based on aggregated columns

I have a table of Agent who first performed an activity A calculated using (PU_FIRST(“Case”,“Activity_Table”.“Agent_Name”,Activity_Name"="Activity_A) and KPI of Number of times a particular activity was repeated within 7 days using :
DATEDIFF(dd,LAG(“WorkOrder”.“CreatedDate”,ORDER BY (“WorkOrder”.“CreatedDate”), PARTITION BY (“Case”.“CaseNumber”)),“WorkOrder”.“CreatedDate”)
< 7 THEN 1 ELSE 0 END) .
I want to rank the agents based on this KPI as another column.
Can you please guide me on how to do the same ?

Thank you for the help :slight_smile: