|
|
Question : Distinct count
|
|
Good Afternoon:
Here is my question:
The data :
cr_urn IN a123 1 a123 1 a123 1 a234 0 a234 0 a234 0 a555 1
I want to at the end of the report to show that I have a total of 2 inpatients .
My attempted soln for inpatient column :
IF NOT ONLASTRECORD THEN IF {NHS_Implant_Report_sp4_test_4.cr_urn}<>NEXT({NHS_Implant_Report_sp4_test_4.cr_urn}) AND {NHS_Implant_Report_sp4_test_4.crp_status}='IN' THEN 1 ELSE 0 ; **************this gives me
a123 0 a123 0 a123 1 a234 0 a234 0 a234 0 a555 0*** this should be one.
I am going for coffee now....I hope you can solve this one..as I know this is a basic question :-)
Thank you, Lucy
|
Answer : Distinct count
|
|
Try it this way
IF NOT ONLASTRECORD THEN IF {NHS_Implant_Report_sp4_test_4.cr_urn}<>NEXT({NHS_Implant_Report_sp4_test_4.cr_urn}) AND {NHS_Implant_Report_sp4_test_4.crp_status}='IN' THEN 1 ELSE 0 Else 1;
The else goes with the second if so no value is returned;
You may actually need to try it this way
IF ONLASTRECORD THEN If ({NHS_Implant_Report_sp4_test_4.crp_status}='IN' ) then 1 Else 0 Else IF {NHS_Implant_Report_sp4_test_4.cr_urn}<>NEXT({NHS_Implant_Report_sp4_test_4.cr_urn}) AND {NHS_Implant_Report_sp4_test_4.crp_status}='IN' THEN 1 ELSE 0
mlmcc
|
|
|
|