@swapnil_J When I have this kind of issue I always relied on Ratio summary method...
Any formula you apply in a module where is used the list Y (detailed level) it will use only the base members of the list Y and it will apply summary methods starting from Y level ONLY. (so, at upper levels you will always have only values of the elements X which have children in the list Y.
Ratio summary method is the only way to have in the same column the values from the list Y and values on the list X without any child in the list Y.
With Ratio summary method you have a limitation: works only for numeric Line-items... ( below the Element "C" does not have children.. In the Using Ratio line-item there are values ...even the formula takes data from 'L2' line-item: (list Y)