Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Diana_B
Contributor II
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:

Diana_B_0-1626178778886.png

"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?

Thank you in advance!

Best regards,
Diana

Labels (2)
1 Solution

Accepted Solutions
MayilVahanan

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
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

3 Replies
MayilVahanan

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
Please close the thread by marking correct answer & give likes if you like the post.
avinashelite

Try like this 

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

Diana_B
Contributor II
Contributor II
Author

Yes, it helped 🙂

The values are exactly wthat I wanted them to be.

Thanks a lot!