I am using one Stacked bar chart to do analysis of product.
I am taking 'year' and 'Product_category' as dimension and 'count of product in percentage' (Count of each product/Count of all the product)as expression . For that I am using the following Expression.
count( distinct if ( Volume > 0, Product))/count({$<Product=>} total distinct if ( Volume > 0, Product))
It shows 100% in chart If I select a particular year. But If I see for all the years, its taking "Count of each product / Count of product for all the year". I need an expression like, If we not select any particular year also it should count each product and do division for that particular year.
For eg:
Year
Product Category
Product in %
Count
I need like
2005
A
0%
0
0
2005
B
1%
2
1.503759
2005
C
0%
1
0.75188
2005
D
12%
38
28.57143
2005
E
1%
4
3.007519
2005
F
14%
43
32.33083
2005
G
15%
45
33.83459
2005
Total
43%
133
100%
2006
A
0%
0
0
2006
B
2%
5
2.777778
2006
C
0%
1
0.555556
2006
D
16%
49
27.22222
2006
E
2%
5
2.777778
2006
F
16%
49
27.22222
2006
G
23%
71
39.44444
2006
Total
58%
180
100%
2007
A
0%
1
2007
B
2%
6
2007
C
0%
1
2007
D
14%
43
2007
E
3%
9
2007
F
15%
48
2007
G
30%
92
2007
Total
65%
200
2008
A
0%
1
2008
B
0%
1
2008
C
0%
0
2008
D
6%
18
2008
E
5%
15
2008
F
1%
4
2008
G
20%
61
2008
Total
32%
100
2009
A
0%
0
2009
B
0%
0
2009
C
0%
0
2009
D
15%
45
2009
E
4%
13
2009
F
0%
0
2009
G
11%
34
2009
Total
30%
92
2010
A
0%
0
2010
B
0%
0
2010
C
0%
0
2010
D
13%
40
2010
E
1%
3
2010
F
0%
0
2010
G
1%
3
2010
Total
15%
46
Total
100%
Products: 310
If I am not selecting any particular year also, It should show me the 100% value for the products.