# Return Data in Same Table

### คำถาม

• Hello,

I have a data table in powerpivot with doctor information and patient information which includes the patients referring doctor.

 Cust Type Customer ID Customer Name Doctor Typ Referring Doctor ID Referring Doctor Name Referring Doctor ID Doctor 00ABC Doctor Dr John Smith M.D. N/A N/A =Doctor's Doc Type Patient 00XYZ Patient Mr. Patient N/A 00ABC Doctor Dr John Smith Should = Referring Doc Type

Does any one know a simple formula that I could add as a calculated column to the referring doctor id field for patients?  This will allow me to roll up sales for a particular doctor type including their patients.

9 กรกฎาคม 2555 18:37

### คำตอบ

• something like

=IF([Cust Type] = "Doctor", [Doctor Type], LOOKUPVALUE(MyTable[Doctor Type], MyTable[Customer ID], MyTable[Referring Doctor ID]))

so if the current row is of type Doctor, we can simply take the DoctorType of the current row
otherwises we have to lookup the DoctorType of the referring Docotor

hth,
gerhard

- www.pmOne.com -

• ทำเครื่องหมายเป็นคำตอบโดย 12 กรกฎาคม 2555 17:10
12 กรกฎาคม 2555 12:22

### ตอบทั้งหมด

• something like

=IF([Cust Type] = "Doctor", [Doctor Type], LOOKUPVALUE(MyTable[Doctor Type], MyTable[Customer ID], MyTable[Referring Doctor ID]))

so if the current row is of type Doctor, we can simply take the DoctorType of the current row
otherwises we have to lookup the DoctorType of the referring Docotor

hth,
gerhard

- www.pmOne.com -

• ทำเครื่องหมายเป็นคำตอบโดย 12 กรกฎาคม 2555 17:10
12 กรกฎาคม 2555 12:22
• Gerhard,

That worked perfectly!  Thank you very much.

Kevin

12 กรกฎาคม 2555 17:10