4 Replies Latest reply on Dec 26, 2013 2:47 AM by Thasan Vallipuranathan

    Adding fields from an Other table to join 2 tables

    jabrane.belghith

      Hi every One;

      I want to join 2 tables ; Table A contain "Dossier" and table B does not contain the same field.

      1.How can I add field "Dossier" to table B ?

      2.Can we Add filelds from tableA and tableB to an other table C that does not exist in the database ( I will create Table C manually)??

      3.Can I Duplicate a field in any table then rename It in the same table , for exemple , I want To duplicate the field "Type" and rename it "Type2" in the same Table??

      Thanks .

        • 1. Re: Adding fields from an Other table to join 2 tables
          Andrew Ball

          Hi Jabrane,

           

          1) Depends on how they are related and whether the two tables are in the same database. If so, just do a standard Join in the tableau data connection window. If there is simple logic you could just use a calculated field instead.

          2) Sort of. You just want a standard join, I think. Just select multiple tables from the initial data connection window. (It may be that you want something more complicated, in which case you might even need Custom SQL)

          3) Whenever you duplicate a field in Tableau, you are not duplicating it in the database, merely in the meta-data layer. Duplicates have to be named something else ("copy" by default, but rename it if you want).

           

          These are the first round answers, but it may be that you need deeper replies, depending on exactly what you are trying to do. I'd also recommend looking at the connecting to data videos from the Tableau online training videos. (Training & Tutorials | Tableau Software)

          • 2. Re: Adding fields from an Other table to join 2 tables
            Thasan Vallipuranathan

            Hi Jabrane,

             

                  To combine two tables with no common fields, you'll need to use a customsql query ( when connecting to data, under step 2 select custom sql').     

             

            CROSS JOIN returns the Cartesian product of rows from tables in the join - it'll produce rows which combine each row from the first table with each row from the second table. In a dummy data set, if I have two tables: Test1 with columns A,B,C & Test2 with D,E,F. I would use the following statement:

             

            SELECT [Test1$].[a] AS [a],

              [Test1$].[b] AS [b],

              [Test1$].[c] AS [c],

              [Test2$].[d] AS [d],

              [Test2$].[e] AS [e],

              [Test2$].[f] AS [f]

            FROM [Test1$],[Test2$]

             

            Alternatively - SELECT * FROM [Test1$], [Test2$]

             

                 To duplicate in Tableau - right click the dimension and select 'Duplicate'.

            1 of 1 people found this helpful
            • 3. Re: Adding fields from an Other table to join 2 tables
              jabrane.belghith

              Thnk you Thasan for your reply,

              I want exactly to add a field from an Excel file, Sheet 1  to a table which added from an oracle database.

              How can I do that with Sql when I want to modify connexion.??

              • 4. Re: Re: Adding fields from an Other table to join 2 tables
                Thasan Vallipuranathan

                Hi Jabrane,

                 

                I presume this is a third table? and a separate data source? does the third table have any relationship to other tables?

                 

                If additional table has a relationship  - Import the Excel file and create a separate connection. If it's a lookup table, you can even past the data, Data > Paste Data. To join this table to previously imported tables, Data > Edit Relationships.

                 

                If it doesn't have relationship and data is from multiple sources - Custom SQL is not written at the table level, rather when creating the connection. Therefore, you might consider importing excel file into oracle and then writing a custom sql in tableau to import from that single connection - or create a view in oracle.