Hello Venkat,
thx for the clarification. No your question is clear. But you cannot solve it with the CASE statement.
The solution for your requirement is much for simpler. Just define a graphical calculation view with an aggregation node where you specify all columns which should be possibly used for grouping as attributes + your measure columns.
Due to the engine behavior the grouping/aggregation will be done depending on the field list you specify in the query (of course special things like the "keep flag" have to be disabled).
More information on the engine behavior can be found in note 1764658.
Regards,
Florian