4 Replies Latest reply on Aug 1, 2018 12:42 PM by Manish Chauhan

# unable to find the logic for the scenario - Case statement

Hi Team,

I Would like to see if any patient visited more than one Doctor,  If yes tag them with Yes else No.

but i have only two columns data one is Patient ID and another one is Doctor ID.  can some one please help me how to resolve this one?

Expected output will be as mentioned below.

Thank you

• ###### 1. Re: unable to find the logic for the scenario - Case statement

You can do this with a couple of calculated fields. Note: These could be crammed into a single field, but I'm doing separate calcs to make it easier to understand:

Doctor Count

// Get the number of distinct doctors for each patient.

{FIXED [Patient ID]: COUNTD([Doctor  ID])}

2+ Doctors

// Did the patient see more than 1 doctor?

IF [Doctor Count]>1 THEN

"Yes"

ELSE

"No"

END

See attached workbook.

• ###### 2. Re: unable to find the logic for the scenario - Case statement

Here It is:

and If you want to see Patient visited Whom, Then

Thanks

Deepak

1 of 1 people found this helpful
• ###### 3. Re: unable to find the logic for the scenario - Case statement

Hi Amly,

Hope you are doing good.

Just follow these steps to achieve what you want.

1 . Drag the DOCTOR ID on the row shelf.

2.  Drag the Patient ID on the row shelf.

3. Now write a  calculation field:

{fixed [PATIENT ID] : if count( [DOCTOR ID]) >=2 then 'Yes' else 'no'}

Now after saving it  Drag this calculation on the Row Shelf.

You will get desired results.

Amly , I am also starting a youtube platform where you can learn more on tableau and Data science. You can  check out videos there . Soon we will start uploading videos. Channel name  : LookPandas Analytics

Moreover I am also starting a channel for solutions to tableau use cases.

You can write to us directly at lookup5pandas@gmail.com  and can get solution videos with proper explanation.

Feel Free to reach out to us.We will be happy to help you.

MAnish Chauhan

1 of 1 people found this helpful
• ###### 4. Re: unable to find the logic for the scenario - Case statement

Hey Amly,

Sorry for type O error ,Just use countdistinct in place of count:

{fixed [PATIENT ID] : if countd( [DOCTOR ID]) >=2 then 'Yes' else 'no'}