5 Replies Latest reply on Jun 28, 2017 11:35 AM by Jim Dehner

# Creating a Calculated Field to flag patient who has multiple visits where one single visit meets criteria

Hello all

This may be very simple and I am just over thinking this.  Here is my problem:

I am trying to create a calculated field that produces a flag, say 'Y' for each patient encounter where there is a qualified Substance for the flag.  Here is a quick chart of the sample data (also attached):

Problem number 1 (requires a solution):  For each Patient ID, flag all records where there are any Substance that qualify (see Patient IDs 1-4).  Each patient could have up to 20 Substance codes, but only one needs to qualify for the patient to be flagged.  The end goal is to count discreet (COUNTD) the Patient Ids that are flagged.

Problem Number 2 – less important, but still trying to accomplish:
I am trying to calculate another field that gives me the last substance code for each patient ID.  I have tried Max calculations, but I am not returning correct results.

Any assistance with this is greatly appreciated!

Dan Gordon

• ###### 1. Re: Creating a Calculated Field to flag patient who has multiple visits where one single visit meets criteria

Hi Dan

see the attached T10.2 workbook

It produces this

The key formula is { FIXED [Patient ID]: max(IFNULL([Substance],""))} -

The code for the substance is the last recorded the number in the right most column is the number of substances

Let me know if that helps

Jim

• ###### 2. Re: Creating a Calculated Field to flag patient who has multiple visits where one single visit meets criteria

Hey Jim,
Thanks for the quick response!  However, we haven't upgraded to 10.2 yet as we have both Server and Desktop.  Could you possibly save down a version?

Thanks,
Dan

• ###### 3. Re: Creating a Calculated Field to flag patient who has multiple visits where one single visit meets criteria

In my experience, you can sometimes down convert a workbook by unzipping the twbx to get the twb file. Opening the twb file (it's just an XML file). and replacing the two times you see version = 10.2 to version = 10.0 or whatever (lines 4 and 10). Then open the twb file in the older version.

There is likely a better/detailed description of this process somewhere on the forums. ... and advice on when it will or will not work.

Jason

• ###### 4. Re: Creating a Calculated Field to flag patient who has multiple visits where one single visit meets criteria

are you on 10.1?

On Wed, Jun 28, 2017 at 1:03 PM, Dan Gordon <tableaucommunity@tableau.com>

• ###### 5. Re: Creating a Calculated Field to flag patient who has multiple visits where one single visit meets criteria

Dan see attached in 10.1

Let me know if this helps

Jim