Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Highlighted
cbushey1
Contributor III

Pivot table %

Hi there,

I am looking for a way for my percentage expression to only display a percentage based on the total that is displaying. I understand that typically you can use the TOTAL prefix in the expression to get the data across the whole database but I need to only display percentages across the 12 months that are displaying.

My Numerator expression is as follows:

=Sum(Aggr(Sum({<Rolling12M_Flag = {1}>}CaseCounter),Date_YM,CancellationReason))

The two fields I am aggregating my CaseCounter over are the dimensions displayed in the pivot chart.

Suggestions?

1 Solution

Accepted Solutions

Re: Pivot table %

In the denominator or numerator or both?

=Sum(Aggr(Sum({<Rolling12M_Flag = {1}, CancellationReason = {'*'}>} CaseCounter), Date_YM, CancellationReason))/Sum({<Rolling12M_Flag = {1}, CancellationReason = {'*'}>} TOTAL Aggr(Sum({<Rolling12M_Flag = {1}, CancellationReason = {'*'}>}CaseCounter), Date_YM, CancellationReason))

7 Replies

Re: Pivot table %

So I am guessing that you are using Rolling12M_Flag to display 12 month period? If that is true, you should be able to do just this:

=Sum(Aggr(Sum({<Rolling12M_Flag = {1}>}CaseCounter),Date_YM,CancellationReason))/Sum(TOTAL Aggr(Sum({<Rolling12M_Flag = {1}>}CaseCounter),Date_YM,CancellationReason))

cbushey1
Contributor III

Re: Pivot table %

Hi Sunny,

Thanks for the post, however I have tried that and it doesn't return the expected results. The problem is that the Total is ignoring my dimensions of Date_YM (i.e. October 2015...) and Cancellation reason and summing all values together. I know I have data outside of the last 12 months and unfortunately that is being included in the denominator.

I have also tried moving total to the inside Sum and many other variations with the Aggr to no avail.

Any other thoughts?

Re: Pivot table %

It might help to see a sample, but try these if you have not already done so

=Sum(Aggr(Sum({<Rolling12M_Flag = {1}>}CaseCounter),Date_YM,CancellationReason))/Sum({<Rolling12M_Flag = {1}>} TOTAL Aggr(Sum({<Rolling12M_Flag = {1}>}CaseCounter),Date_YM,CancellationReason))

Also, are you using calculated dimension or dimension limits in your chart?

cbushey1
Contributor III

Re: Pivot table %

I think this might have done it for me.

Is it possible to have this calculation ignore nulls?

I found I also have some nulls in my CancellationReason field.

Re: Pivot table %

In the denominator or numerator or both?

=Sum(Aggr(Sum({<Rolling12M_Flag = {1}, CancellationReason = {'*'}>} CaseCounter), Date_YM, CancellationReason))/Sum({<Rolling12M_Flag = {1}, CancellationReason = {'*'}>} TOTAL Aggr(Sum({<Rolling12M_Flag = {1}, CancellationReason = {'*'}>}CaseCounter), Date_YM, CancellationReason))

Re: Pivot table %

may be

Sum(Aggr(Sum({<Rolling12M_Flag = {1},CancellationReason ={'*'}-{''}>}CaseCounter),Date_YM,CancellationReason))/Sum({<Rolling12M_Flag = {1},CancellationReason ={'*'}-{''}>}CaseCounter>} TOTAL Aggr(Sum({<Rolling12M_Flag = {1}>}CaseCounter),Date_YM,CancellationReason))

cbushey1
Contributor III

Re: Pivot table %

Thanks! That did the trick for me.