Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

decile creation

hi everyone,

we have a DB of fidelity card. Each card has his sales value and we would like to create sales decile. For example in excel:   we order fidelity card for decreasing sales value, then we calculate percentage share, then we calculate cumulate share so the first decile is composed by the ffidelity card those make the first 10%  of cumulate share.

this for each pharmacy.

we try with this 

=if(aggr(Sum(VALORE),TESSERA) <= fractile(TOTAL aggr(Sum(VALORE),TESSERA), 0.10), 1,
if(aggr(Sum(VALORE),TESSERA) <= fractile(TOTAL aggr(Sum(VALORE),TESSERA), 0.20), 2,
if(aggr(Sum(VALORE),TESSERA) <= fractile(TOTAL aggr(Sum(VALORE),TESSERA), 0.30), 3,
if(aggr(Sum(VALORE),TESSERA) <= fractile(TOTAL aggr(Sum(VALORE),TESSERA), 0.40), 4,
if(aggr(Sum(VALORE),TESSERA) <= fractile(TOTAL aggr(Sum(VALORE),TESSERA), 0.50), 5,
if(aggr(Sum(VALORE),TESSERA) <= fractile(TOTAL aggr(Sum(VALORE),TESSERA), 0.60), 6,
if(aggr(Sum(VALORE),TESSERA) <= fractile(TOTAL aggr(Sum(VALORE),TESSERA), 0.70), 7,
if(aggr(Sum(VALORE),TESSERA) <= fractile(TOTAL aggr(Sum(VALORE),TESSERA), 0.80), 8,
if(aggr(Sum(VALORE),TESSERA) <= fractile(TOTAL aggr(Sum(VALORE),TESSERA), 0.90), 9,10)))))))))

but doesn't work.

there is someone that can help me?

thanks

1 Solution

Accepted Solutions
sunny_talwar

Are you using QlikView 12.1 or above or Qlik Sense... you can try this

Dimension

=Aggr(If(RangeSum(Above(Sum([SUM(VALORE) - SALES]), 0, RowNo()))/Sum(TOTAL [SUM(VALORE) - SALES]) < 0.1, 1,
	 If(RangeSum(Above(Sum([SUM(VALORE) - SALES]), 0, RowNo()))/Sum(TOTAL [SUM(VALORE) - SALES]) < 0.2, 2,
	 If(RangeSum(Above(Sum([SUM(VALORE) - SALES]), 0, RowNo()))/Sum(TOTAL [SUM(VALORE) - SALES]) < 0.3, 3,
	 If(RangeSum(Above(Sum([SUM(VALORE) - SALES]), 0, RowNo()))/Sum(TOTAL [SUM(VALORE) - SALES]) < 0.4, 4,
	 If(RangeSum(Above(Sum([SUM(VALORE) - SALES]), 0, RowNo()))/Sum(TOTAL [SUM(VALORE) - SALES]) < 0.5, 5,
	 If(RangeSum(Above(Sum([SUM(VALORE) - SALES]), 0, RowNo()))/Sum(TOTAL [SUM(VALORE) - SALES]) < 0.6, 6,
	 If(RangeSum(Above(Sum([SUM(VALORE) - SALES]), 0, RowNo()))/Sum(TOTAL [SUM(VALORE) - SALES]) < 0.7, 7,
	 If(RangeSum(Above(Sum([SUM(VALORE) - SALES]), 0, RowNo()))/Sum(TOTAL [SUM(VALORE) - SALES]) < 0.8, 8,
	 If(RangeSum(Above(Sum([SUM(VALORE) - SALES]), 0, RowNo()))/Sum(TOTAL [SUM(VALORE) - SALES]) < 0.9, 9, 10))))))))), ([TESSERA (FIDELITY CARD)], (=Sum([SUM(VALORE) - SALES]), DESC)))

Expression

=Count( [TESSERA (FIDELITY CARD)])

View solution in original post

7 Replies
sunny_talwar

What issues or errors are you running into when you use this?

Anonymous
Not applicable
Author

with istruction writed before we have

Decilinumber card
1891
2890
3890
4891
5890
6888
7892
8881
9884
10908

 

but what we expect is

DeciliNumber card
1201
2259
3400
4500
5700
6985
71158
82500
93890
105400

 

where in the first decile there are less number card then the 10th decile because in the firt decile there are most valueble cards instead in the 10th decile there are low budget cards.

thanks

 

 

sunny_talwar

Decile function divides your data into 10 equal parts... which is why you are seeing almost the same number of observations within each bucket. I am not sure I understand the logic behind your expected output. Would you be able to share a sample to look at this?
Anonymous
Not applicable
Author

In attached you can find a example where i select one pharmacy and the period giuly - october.

i hope that you can understand.

sunny_talwar

Are you using QlikView 12.1 or above or Qlik Sense... you can try this

Dimension

=Aggr(If(RangeSum(Above(Sum([SUM(VALORE) - SALES]), 0, RowNo()))/Sum(TOTAL [SUM(VALORE) - SALES]) < 0.1, 1,
	 If(RangeSum(Above(Sum([SUM(VALORE) - SALES]), 0, RowNo()))/Sum(TOTAL [SUM(VALORE) - SALES]) < 0.2, 2,
	 If(RangeSum(Above(Sum([SUM(VALORE) - SALES]), 0, RowNo()))/Sum(TOTAL [SUM(VALORE) - SALES]) < 0.3, 3,
	 If(RangeSum(Above(Sum([SUM(VALORE) - SALES]), 0, RowNo()))/Sum(TOTAL [SUM(VALORE) - SALES]) < 0.4, 4,
	 If(RangeSum(Above(Sum([SUM(VALORE) - SALES]), 0, RowNo()))/Sum(TOTAL [SUM(VALORE) - SALES]) < 0.5, 5,
	 If(RangeSum(Above(Sum([SUM(VALORE) - SALES]), 0, RowNo()))/Sum(TOTAL [SUM(VALORE) - SALES]) < 0.6, 6,
	 If(RangeSum(Above(Sum([SUM(VALORE) - SALES]), 0, RowNo()))/Sum(TOTAL [SUM(VALORE) - SALES]) < 0.7, 7,
	 If(RangeSum(Above(Sum([SUM(VALORE) - SALES]), 0, RowNo()))/Sum(TOTAL [SUM(VALORE) - SALES]) < 0.8, 8,
	 If(RangeSum(Above(Sum([SUM(VALORE) - SALES]), 0, RowNo()))/Sum(TOTAL [SUM(VALORE) - SALES]) < 0.9, 9, 10))))))))), ([TESSERA (FIDELITY CARD)], (=Sum([SUM(VALORE) - SALES]), DESC)))

Expression

=Count( [TESSERA (FIDELITY CARD)])
Anonymous
Not applicable
Author

hello i use Qlik sense and using your formula in dimention, i get only 1 decile (you can see it in attached)

Anonymous
Not applicable
Author

Hello thanks very much. i change the field [Sum (value)] with value and now it works.

thannks