Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Pivot Table Aggregation Help

I am creating the following Pivot Table. The data contains multiple policies whose Premiums, Earned Premiums, etc are being calculated by normal Sum formula in the pivot. If you look at the last column Profit Retained the sub-total should be a sum of the values above. Instead its is calculating it based the sub-total row.

Retention % = Sum (Retained Premiums) / Sum (Premiums)

Profit = Sum (Earned Premium) - Sum (Incurred Claims)

Profit Retained = [Profit] * [Retention %]

For individual rows the profit retained is coming correctly. However, for the sub-total I do not want it to multiply but just take total of the already calculated values. Right now it is showing 3730390 (i.e. 47.2% * 7904837) however, if you total the individual rows it comes to -1922125.


RA_Year

LOB PremiumsEarned PremiumIncurred ClaimsRetention %ProfitProfit Retained
2010CARGO106460106460066.4%8250954760
CASUALTY74595374595335983299.4%200218198937
ENGINEERING & CONSTRUCTION7454665745466581952236.3%49643441803044
MARINE HULL509154509154029.6%394594116941
MEDICAL6468720646872011042546100.0%-5708491-5708491
MOTOR795587795587133776100.0%483232483232
PERSONAL ACCIDENT289628960100.0%22452245
PROPERTY104172521041725232675215.1%74861871127206
Total 26500687 26500687 12682428 47.2% 7904837 3730390

Can you please guide me as to what I am doing wrong here.

Thanks in advance.

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Below expression may help you to achieve expected result,

Sum(Aggr(Sum ([Retention %])*Sum(Profit),LOB))

View solution in original post

7 Replies
SergeyMak
Partner Ambassador
Partner Ambassador

Hi

Your wrote that Profit = Sum (Earned Premium) - Sum (Incurred Claims)

I see that the first row has wrong value of profit, because Earned Premium=106460, Incurred Claims = 0, but Profit is not equal 106460. So something wrong.

Please share your app.

Regards,
Sergey
Not applicable
Author

Actually Profit has many other elements in it. I wanted to keep it simple that is why I only wrote 2 items.

The actual formula is - Profit = sum(PREMIUM *  $(vEarned_Factor) * .925) - (SUM(GROSS_CLAIM_PAID) + sum(OSLR) + sum($(vIBNR))) - SUM(COMMISSION *  $(vEarned_Factor)) + SUM(RI_COMMISSION *  $(vEarned_Factor))

The profit column is working correctly.

I am having issues in the sub-total for Profit Retained. I do not want it to calculate from the sub-total row but from base data as there will be differences due to the weightages.

SergeyMak
Partner Ambassador
Partner Ambassador

Can you share your app?

Regards,
Sergey
Not applicable
Author

Due to Data Protection issues I cannot upload the QVW file. However, I attach an excel file which would help in getting my point across.

Columns A to K are coming from the Pivot Table which I have created. Column M recalculates the Column J which is ok. And Column N recacluates Column K as Qlikview is doing and Column O shows what I want. The difference is basically in the way it is handling sub-totals. Due to the mix of business, recalculating at the sub-total level gives a wrong answer.

Hope this clarifies.

Thanks.

SergeyMak
Partner Ambassador
Partner Ambassador

Unfortunately excel file doesn't help.

I need your app to see formulas and data model.

For security reasons you can Reduce the data (File\Reduce data) and/or scramble data (Settings\Document Properties\Scrambling then select needed field and click Scramble).

I can't help you without your app

Regards,
Sergey
Anonymous
Not applicable
Author

Below expression may help you to achieve expected result,

Sum(Aggr(Sum ([Retention %])*Sum(Profit),LOB))

Not applicable
Author

Thanks Satyadev

The Aggregate sandwiched between the sums helped and it is working now. Also we cannot use the field names like [Retention %] we need to give the full formula but thats just copy paste.

Thanks once again as you helped solve a major issue.