Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
sweens78
Creator
Creator

Subtracting to values

Hi Guys

I'm try to subtract the two formula below when I do them individually I get correct answer but when I try to then subtract the two formula my answer is wrong, out by 4!  Any ideas where I may be going wrong? Think I may have too many counts?

Formula 1 count(if(Interventions_ID='4', NEWKEYID))-Count(if( Interventions_ID= '4', PatientsNotAssessed_ID)) correct answer

Formula 2 count(if(Interventions_ID='5', NEWKEYID))-Count(if( Interventions_ID= '5', PatientsNotAssessed_ID)) correct answer

subtract the two?? Getting wrong answer

count(if(Interventions_ID='4', NEWKEYID))-Count(if( Interventions_ID= '4', PatientsNotAssessed_ID))-count(if(Interventions_ID='5', NEWKEYID))-Count(if( Interventions_ID= '5', PatientsNotAssessed_ID))

Labels (1)
1 Solution

Accepted Solutions
rubenmarin
MVP
MVP

Hi Martin, I think is a parenthesys issue:

count(if(Interventions_ID='4', NEWKEYID))-Count(if( Interventions_ID= '4', PatientsNotAssessed_ID))-(count(if(Interventions_ID='5',NEWKEYID))-Count(if( Interventions_ID= '5', PatientsNotAssessed_ID)))

View solution in original post

5 Replies
rubenmarin
MVP
MVP

Hi Martin, I think is a parenthesys issue:

count(if(Interventions_ID='4', NEWKEYID))-Count(if( Interventions_ID= '4', PatientsNotAssessed_ID))-(count(if(Interventions_ID='5',NEWKEYID))-Count(if( Interventions_ID= '5', PatientsNotAssessed_ID)))

trdandamudi
Master II
Master II

Can you please attach a sample app ? or give a try with the below:

count({<Interventions_ID={4}>}, NEWKEYID)-Count({<Interventions_ID={4}>}, PatientsNotAssessed_ID)-count({<Interventions_ID={5}>}, NEWKEYID)-Count({<Interventions_ID={5}>}, PatientsNotAssessed_ID)

sweens78
Creator
Creator
Author

Great Job Ruben!

sweens78
Creator
Creator
Author

Ruben,

I just want to get a percentage of the above as well im trying to do it this way but still no good any

thoughts?

=NUM((count(if(Interventions_ID='4', NEWKEYID))-Count(if( Interventions_ID= '4', PatientsNotAssessed_ID))-(count(if(Interventions_ID='5',NEWKEYID))-Count(if( Interventions_ID= '5', PatientsNotAssessed_ID))) / ((Count(NEWKEYID)-Count(PatientsNotAssessed_ID)),'##.##%'))

rubenmarin
MVP
MVP

Hi, if you want the percentaje of Intervention_ID 4 over the ID 5, the second part of division needs the same check to retrieve only the ID 5.

(count(if(Interventions_ID='4', NEWKEYID))-Count(if( Interventions_ID= '4', PatientsNotAssessed_ID))-(count(if(Interventions_ID='5',NEWKEYID))-Count(if( Interventions_ID= '5', PatientsNotAssessed_ID)))) / (count(if(Interventions_ID='5',NEWKEYID))-Count(if( Interventions_ID= '5', PatientsNotAssessed_ID)))

Also, the use of 'If()' in this expression can be improved using set analysis:

"count(if(Interventions_ID='4', NEWKEYID))" can be "Count({<Interventions_ID={'4'}>} NEWKEYID)"