Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
vidyasagar159
Creator II
Creator II

Calculate Percentage of Multidimensional columns

Hello Community,

I want to create a Percentages based on the range of Amount by Year and Company. Please find the details below. I tried a couple of approaches but I am not able to achieve the expected result.

Actual Table:

YearCompanyAmount
2010Apple10
2010Nokia20
2010Samsung30
2010Apple100
2010Nokia200
2010Apple500
2011Nokia100
2011Samsung200
2012Apple500
2012Nokia150
2014Apple600
2014Nokia100
2014Samsung150
2014Apple300
2014Nokia200

Result Table: This is giving me the percentages of all the years.

YearCompanyPlan SizeTotal AmountPercentages
Totals3160100%
2010AppleGreate than 50061019%
Nokia50-7002207%
SamsungLess then 50301%
2011Nokia100-2001003%
Samsung100-2002006%
2012Apple50-70050016%
Nokia100-2001505%
2014AppleGreate than 50090028%
Nokia50-7003009%
Samsung100-2001505%

Dimension Expression:

Plan Size:


if(aggr(sum(Amount),Year,Company)<50,'Less then 50',

if(aggr(sum(Amount),Year,Company)>=100 and aggr(sum(Amount),Year,Company)<=200 ,'100-200',

if(aggr(sum(Amount),Year,Company)>500,'Greate than 500',

if(aggr(sum(Amount),Year,Company)>50 and aggr(sum(Amount),Year,Company)<700 ,'50-700',

))))

Measure Expression:

Total Amount:

(sum(total<Year,Company>Amount))

Percentage Amount:

sum(Amount)/(sum(total{$<Year,Company>}Amount))

But the Expected Result I want is to show the 100% split per each year.

Expected Result:

YearCompanyPlan SizeTotal AmountPercentages
2010AppleGreate than 50061071%
2010Nokia50-70022026%
2010SamsungLess than 50303%
Total 860100%
2011Nokia100-20010033%
2011Samsung100-20020067%
Total 300100%
2012Apple50-70050077%
2012Nokia100-20015023%
Total 650100%
2014AppleGreate than 50090067%
2014Nokia50-70030022%
2014Samsung100-20015011%
Total 1350100%

Also, I will convert this table to 100% Stacked bar color by PLAN SIZE. So that I can see how much percentage of plan size for each year.

Thanks in Advance,

-Vidya

16 Replies
sunny_talwar

But then why not just do like how he is doing if we have to use Aggr()

sunny_talwar

Meaning this

Sum(Amount)/Aggr(nodistinct sum(Amount),Year).

OmarBenSalem

I havnt seen the full discussion.. my bad !

Well, It's 10 pm in France.. so, I'm doing this out of passion; can't blame me if I don't read it all

vidyasagar159
Creator II
Creator II
Author

So, is there any difference between the 2 Expressions? Like performance optimization?

Thanks,

-Vidya

vidyasagar159
Creator II
Creator II
Author

Guys. In the first place, i am really thankful to all of you for looking into this.

sunny_talwar

From what I see your expression should be slightly better performing because you are aggregating over a single dimension. But I havn't done testing to prove it. May be you can test to see which one works better

vidyasagar159
Creator II
Creator II
Author

So, With all the respect and information provided by the gentlemen in this thread. Both the expressions will give the right output.

Measure Expressions:

Sum(Amount)/Aggr(nodistinct sum(Amount),Year)

OR

sum(Amount) / aggr(sum(total <Year> Amount),Year,Company)

Since my report consuming more than 10 Million records of data. I have to test which is the better one in terms of

performance.

Thanks,

-Vidya