# QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Support Cases coming to Qlik Community Oct. 4! Start chats, open cases, explore resources: READ DETAILS
cancel
Showing results for
Did you mean:
Contributor II

## Wrong values in total row in pivot table

Hi!

Can you help me with the following problem?

I want to show the sum of each field in the pivot table.

Unfortunataly it doesn’t work to sum the values for the following field:
„Therapiedauer in Stunden“.

Furthermore the sum for the following field is calculated wrongly:
„Therapiedauer in Stunden pro Woche“.

What can I do to get the correct sum for each field?

Many thanks in advance for your help!

Best regards,

Diana

1 Solution

Accepted Solutions

Try these expressions.

1. Therapiedauer in Stunden :

Sum(Aggr(Sum(Therapieanzahl) * Therapiedauer_in_Stunden,[Patienten-ID],[KTL-Code]))

2. Therapiedauer in Stunden pro Woche:

Sum(aggr((Sum(Therapieanzahl)*Max(Therapiedauer_in_Stunden))/Max([Aufenthaltsdauer in Wochen]),[Patienten-ID],[KTL-Code]))

Regards,
Kaushik
If reply is satisfactory, please "Like" the post.
If reply is solution, please mark as "Correct".
4 Replies

What is the expected result?

Regards,
Kaushik
If reply is satisfactory, please "Like" the post.
If reply is solution, please mark as "Correct".
Contributor II
Author

The excpected result for column "Therapiedauer in Stunden" is 36451,21; the sum of all values, when the pivot table is expanded.
The excpected result for column "Therapiedauer in Stunden pro Woche" is 11779,37; also the sum of all values, when the pivot table is extended.

I say "the sum when the pivot is extended", because there is also a problem with the totals for each "Patienten-ID" when the fields of the pivot-table are collapsed.
E. g. for Patienten-ID 100001 there is no shown (collapsed) value for column "Therapiedauer in Stunden" but it should be 34,92 and for column "Therapiedauer in Stunden pro Woche" the collapsed value is 33,38 but it should be 17,49.

Try these expressions.

1. Therapiedauer in Stunden :

Sum(Aggr(Sum(Therapieanzahl) * Therapiedauer_in_Stunden,[Patienten-ID],[KTL-Code]))

2. Therapiedauer in Stunden pro Woche:

Sum(aggr((Sum(Therapieanzahl)*Max(Therapiedauer_in_Stunden))/Max([Aufenthaltsdauer in Wochen]),[Patienten-ID],[KTL-Code]))

Regards,
Kaushik
If reply is satisfactory, please "Like" the post.
If reply is solution, please mark as "Correct".
Contributor II
Author

Thank you so much!

I have tried it with the aggregation before, but apparently I made a mistake somewhere.

This works perfectly!

Best regards,
Diana

Community Browser