Find out the top 5 channels and accordingly their top brands and top depts .
TOP 5 Channel
Channel : Channel 10
Top Brand :
Channel : Channel 1
Top Brand :
The approach I was following:
* I analysed the data and manually found out the top 5 channels.
* I had used set analysis to find out the top dept and top brand in each of the 5 channels.
* But I had hard coded the top channels, e.g 1st channel as channel 10 2nd as channel 1 likewise . But hard coding is not a viable option as top 5 would keep changing.
* So I found out the top 5 channels using aggr() and rank function.
This worked fine. I got the top 5 channels.
* I intended to use them in set analysis in the place of the hard coded values. So, I stored them in variables. But problem is aggr() returns in number format and the channel field is string in db. So when I store the aggr() resut in a var and use set analysis with that var it returns me null because it is probably searching for a number and not getting it.
Rank1 is a variable containing : Aggr(if(Rank(Sum(Sales))=1,Channel),Channel)
e.g: the first ranked channel is channel 10 say suppose. But aggr() is returning to the set analysis expression as the numerical equivalent of channel10 maybe. This it cannot seem to find out.
Am I going the right way? Is there a way to typecast the return type of aggr()? Please provide the solution?