Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Count + Agg

I need to get a count of how many A1c's with a value greater than 7 using an expression within a bar chart.

This is what I have thus far...

Count(NAME = 'A1c') and if(OBSVALUE > 7,OBSVALUE)

Of course this did not work for me. Any ideas?

18 Replies
Not applicable
Author

UserNAMEDateValue
AmyA1c20145.1
BryanA1c20148.2
GuyLDL2014150
CarolA1c201412.6
SarahLDL2014200
BrendaSmoke Cessation2014Yes

I can't send what I have do to HIPAA (medical law) but, I put this example together which I hope helps.

JonnyPoole
Employee
Employee

  was afraid of that.  Here is used this expression:

count (if( NAME = 'A1c' and Value > 5, NAME))

Attached is the app for your reference. its an inline load so you can change the data if you need to replicate the issue.

let me know your thoughts

Capture.PNG.png

to get this

Not applicable
Author

The statement makes sense to me however, my results are "no data." I've been lost on this one for some time. I appreciate all your help! 

JonnyPoole
Employee
Employee

Are your results 'no data' with my sample or your QVW ?   I believe the sample works for you just wanted to check.

Are you able to share your QVW ? or some reduced or scrambled version ?   There is a scramble feature on the document properties and you could load much reduced data by altering hte load script and removing fields and adding where filters... ?

Not applicable
Author

I tried going this route (see below) and it looked closer to what I was after however, the count is not correct. The table chart is the total number of actual records where the bar chart is .... well.... a much higher number.

I added the value into the dimension list and used the expression below.

expression: count({<NAME = {'A1c'}, OBSVALUE = {'>7'}>}NAME)

graph2.JPG.jpg

JonnyPoole
Employee
Employee

hmmm... i wonder if its double or triple counting the records. Whichever way you try  whether its a count(if () ) or a count( {SET} )  ,  try adding a DISTINCT in there and possible concatenating the NAME with the VALUE:

Test 1:  count( distinct  {<NAME = {'A1c'}, OBSVALUE = {'>7'}>}NAME)

Test 2:  count( distinct  {<NAME = {'A1c'}, OBSVALUE = {'>7'}>}  NAME&OBSVALUE )


Not applicable
Author

Genius! Test 2 worked like a charm. All the records are matching up! Thank you so much for help me on this!

JonnyPoole
Employee
Employee

ok. thats going to count each unique combination of name and obsvalue.

Would you ever need to count a single combination of NAME and OBSVALUE more than once ?  If the answer is no, then you should be good.

glad we made progress.

Not applicable
Author

No. This is perfect.