Hi Ani,
We have two options.
1 Write start routine to determine Expand or Close, but this option is not recommended because data might change so in result might not be correct all the time.
2 Implement virtual characteristic concept it will calculate at runtime, so that result will be correct.
http://scn.sap.com/docs/DOC-57719
Regards,
Nanda