There are only 2 groups.
Group #1 (folder )------ this is where the formula is placed)
Group #2 object, schedule Instance, Viewed Instance, date
When i use the following formula I get the root folder and all the objects under it (there is no subfolders being displayed and there is no duplication too)
stringvar x := {Command.DETAIL_TEXT};
stringvar y := right(trim(x),len(trim(x))-1);
left(y, InStr(y, '/') - 1)
This is how the shedule and view is obtained in the sql command
CASE
WHEN audit.event_id in ( 1000,1001) THEN 1
ELSE 0
END AS Schedule_Instance,
CASE WHEN audit.event_id IN (2000, 2001) THEN 1
else 0 END as View_Instance,