Sean
Sean

Reputation: 631

"Inserting" Records into Fields from a Database Feed

So the background to this is I'm trying to create a survival curve based on a database feed from the directions here.

What I have so far is three calculated fields per below. Patient ID is not a calculated field or necessary for the survival analysis, but I believe it could be useful for this question. For reference, there are about 20,000 unique patients.

Patient ID | Time | Censor | Group

   Id1        3       0        1
   Id2        8       0        2
   Id3        1       1        1
   Id4        3       1        1
   Id5        11      0        1
   Id5        7       1        2

What I would like to do is insert two records (one for each group) such:

Patient ID | Time | Censor | Group | Link

              0                1
              0                2
   Id1        3       0        1     link
   Id2        8       0        2     link
   Id3        1       1        1     link
   Id4        3       1        1     link
   Id5        11      0        1     link
   Id5        7       1        2     link

I unsuccessfully tried to create an excel spreadsheet with these base attributes to union with the columns, however, an excel spreadsheet does not appear to be able to union with a database.

My next idea is to find 2 of the 20,000 patients where I can create a calculated field along these lines (not sure this is feasible in Tableau, please excuse my syntax):

IF [Patient ID] = Id3 THEN [TIME] = 0 AND [CENSOR] IS NULL
END

and then a [Link] calculated formula:

IF [Patient ID] = Id3 THEN NULL
ELSE "link"
END

Any help would be appreciated. Would like to avoid inserting these records in the database.

Upvotes: 0

Views: 51

Answers (1)

Aron
Aron

Reputation: 775

The best / easiest option is to use an outer join to your excel workbook -- this is a new feature in Tableau version 10 (Cross database joins)

Then, once the dataset is combined, you can build business logic through a filter or calculated field based on the absence or presence of the Excel data.

http://www.tableau.com/about/blog/2016/7/integrate-your-data-cross-database-joins-56724

enter image description here

Upvotes: 1

Related Questions