# QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join us for a live Q&A! September 21, 10 AM ET - Onboarding Fast in Qlik Sense SaaS! REGISTER
cancel
Showing results for
Did you mean:
Contributor II

## Divide calculated values in pivot table by total row

Hi,

I read a lot of responses to former questions in the forum, but none of the suggested solutions worked for me.

I have following table:

"Anzahl Patient pro Therapieklasse" is a calculated field:

count(Distinct [Patienten-ID])

Now in the field "Anteil Patienten mit Therapieklasse" I want to divide "Anzahl Patient pro Therapieklasse" by the total value (543). Example: for "Therapieklasse A": 505/543 = 93,00.
The total value of 543 shows the number of all patients.
One patient can have more than one "Therapieklasse". Therefore the total vaule 543 is not equal to the sum of all rows.

As suggested in other forum entries I already tried to use this experssion:
(sum(count(Distinct [Patienten-ID]))) / (sum(TOTAL <Therapieklasse> (count(Distinct [Patienten-ID]))))
but it doesn't work.

Can you please tell me what I made wrong or which expression I should use?

Best regards,
Diana

Labels (2)

• ### Scripting

1 Solution

Accepted Solutions
MVP

Hi Diana,

Try like below

Assign the variable with the formula like below

vNoOfPatients  = count(Distinct [Patienten-ID])

If we use equal assign, it calculates the formula and will store 543 in the vNoOfPatients

in the chat, try like below

= count(Distinct [Patienten-ID]) / vNoOfPatients

Hope it helps.

Else, pls attach the sample file

Thanks & Regards,
Mayil Vahanan R
3 Replies
MVP

Hi Diana,

Try like below

Assign the variable with the formula like below

vNoOfPatients  = count(Distinct [Patienten-ID])

If we use equal assign, it calculates the formula and will store 543 in the vNoOfPatients

in the chat, try like below

= count(Distinct [Patienten-ID]) / vNoOfPatients

Hope it helps.

Else, pls attach the sample file

Thanks & Regards,
Mayil Vahanan R
MVP

Try like this

count(Distinct [Patienten-ID]) /count(Distinct  TOTAL [Patienten-ID])

Contributor II
Author

Yes, it helped 🙂

The values are exactly wthat I wanted them to be.

Thanks a lot!

Community Browser