Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
daumkep
Contributor II
Contributor II

Conditional multiplication in Qlikview

Dear all,

I have the following situation:

I have a stable table "Overview" with different values for different symptoms.

grafik.png

I now want to calculate an overall score for each patient. the score shall multiply all LR+/LR- scores of all symptoms of each patient. If a patient has a symptom, it shall multiply LR+, otherwise LR-.

Some examples:
Patient A has symptoms 'Hypertension' and 'Obesity' => Score(A) = 1,126*1,333 = 1.5
Patient B has no symptoms => Score(B) = 0,857*0,5 = 0,42
Patient C has symptom 'Obesity', but no 'Hypertension' = > Score(C) = 1,126 * 0,5 = 0,563

The formula I search for, needs to do something like this:

for eachPatient in Patient:
  score(eachPatient) = 1
  for symptom in symptoms:
    if symptom in PatientSymptoms:
      score = score*LR+
   else:
      score = score*LR-

The output table shall look like this:
A;1.5
B;0.42
C;0.563
...

Does somebody know how to do this and could give me advise on it?

Thanks a lot for your help

Philipp

 

10 Replies
Shubham_Deshmukh
Specialist
Specialist

HI Philipp,
Can you please elaborate this,
Some examples:
Patient A has symptoms 'Hypertension' and 'Obesity' => Score(A) = 1,126*1,333 = 1.5
Patient B has no symptoms => Score(B) = 0,857*0,5 = 0,42
Patient C has symptom 'Obesity', but no 'Hypertension' = > Score(C) = 1,126 * 0,5 = 0,563
What is score(A) , score(B) as they are in list box
daumkep
Contributor II
Contributor II
Author

Hi Shubham,

the scores are exactly, what I try to calculate. They are not yet in a listbox, but I try to bring them in one.

I have the table 'Overview' which is so far independent of the listboxes PatientSymptoms and Patient. I try to create another listbox (or something similar) which contains 2 columns, one for the Patients (A, B, C...) and one for the score. The Score shall calculate somehow like this:

=Product(If(Symptom = PatientSymptoms;then LR+;else LR-))

So it shall contain the following numbers:

A;1.5
B;0.42
C;0.563

So for Patient A, who has both Symptoms 'Obesity' and 'Hypertension', it shall multiply 1,126*1,333. For Patient B who has no symptoms, it shall multiply 0,857*0,5. Patient C who has 'Obesity', but no 'Hypertension' 1,126*0,5

I hope it is it easier to understand now? Thank you very much for your help.

All the best
Philipp

daumkep
Contributor II
Contributor II
Author

Anybody who could help me with this?

Thanks a lot
Philipp
Shubham_Deshmukh
Specialist
Specialist

Sorry Daumkep, I didn't receive your last notification.
Can you share sample data so that I can try this with your data
daumkep
Contributor II
Contributor II
Author

Hi Shubam,

sure. I sitll use the personal Qlikview edition, but with a Server edition you can still open it, right? Enclosed is also the little Excel sheet that I imported. Please let me know if you have any questions on it. Thanks a lot for you help.

Philipp

Shubham_Deshmukh
Specialist
Specialist

NO I cannot open tha file but let me try.

Also in Prevalence tab you don't have data of LR , so I will add that data as per your snapshot.

Shubham_Deshmukh
Specialist
Specialist

Is your LR data fixed?
Is it in excel sheet,if yes does it gone change in future?
daumkep
Contributor II
Contributor II
Author

Yes, it is pretty much fixed (at least there is no drilldown when you click on patients. The values Apriori, Sensitivity, Specificity, LR+ and LR+ are computed based on the 'Prevalence' attribute, but that's pretty it.

grafik.png

Shubham_Deshmukh
Specialist
Specialist

Hi @daumkep ,

Sorry for late reply, I was working on your data.

You need to connect both data to make them work together like this,

 AA:
LOAD Patient, 
     Symptom
FROM
[C:\Users\KT3028\Downloads\DemoData.xlsx]
(ooxml, embedded labels, table is Symptoms);
join(AA)
BB:
LOAD Symptom, 
     Prevalence, 
     [LR+], 
     [LR-]
FROM
[C:\Users\KT3028\Downloads\DemoData.xlsx]
(ooxml, embedded labels, table is Prevalence);

Then data will be like this,

ggg.png

 

 

 

 

 

 

I am unable to make it in list box or table but able to make it in different text boxes but I think it is not correct as patient number will be dynamic.

Hope this will help you at least up to some extent.

='A - '& only(if(Symptom='Obesity',[LR+]))*only(if(Symptom='Hypertension',[LR+]))

='B - '& (if(isNull(Symptom),only(if(Symptom='Obesity',[LR-]))*only(if(Symptom='Hypertension',[LR-]))))

='C - '& only(if(Symptom='Obesity',[LR+]))*only(if(Symptom='Hypertension',[LR-]))

Regards,

Shubham