7 Replies Latest reply on Dec 7, 2018 4:49 AM by Randy Demaree

    Multiple Condition Data Joins

    Randy Demaree

      I have the nice little connection posted above.  The table A is connected to B through the Green (Usually), A to C and D via Orange, C to E via Teal, and E to F via Blue.

       

      As you can see there are some circumstances in which the first connection is broken due to the connecting point referencing another column.  (Specifically the B Connection Green = E Connection Teal for the last six).  So I was wondering if there was a way to say for it to normally to connect to Green, but if it breaks connect to Teal?

       

      Also it might be good to note that the "Dest Type" column is a good flag to work off of in this scenario.  So if I could say:

      "If Dest Type = 1

           Teal

      Else

           Green"

      That would be very advantageous to me in this scenario!

       

      Hopefully this abstracted information makes enough sense to be able to decipher.

       

      Thanks!

        • 1. Re: Multiple Condition Data Joins
          Chris McClellan

          For me it's hard to figure out the answer because it all depends on how the join is defined.  I can see that the last 6 rows have a NULL in A, but if the condition is tricky is this a case for Tableau Prep to precalculate the join (in the 2 different ways) and then union the result ?

          • 2. Re: Multiple Condition Data Joins
            Randy Demaree

                 That is kind of part of the problem.  The relationship between all these ID's is known intrinsically by the database, and being able to see that relationship outside of the database is not too difficult.  I'm just not sure how to connect it within Tableau.  Really at the end of the day I'm curious if anyone knows of a way to be able to connect based off one ID or another ID based on a third ID.

             

                 So in the picture above, could I connect on Green under normal conditions (Dest type = 3) and Teal under the abnormal (Dest type = 1)?

            • 3. Re: Multiple Condition Data Joins
              Chris McClellan

              Yes, definitely a conditional join (as you first described), but that's probably best handled before the data gets to Tableau - a view in the database maybe ?  Where you can create all the individual conditions (being different joins) and unioning the results.

               

              Can you supply this mockup data as a SQL script or separate CSV files ?

              • 4. Re: Multiple Condition Data Joins
                Randy Demaree

                     Here are all the ID's with the relations in the same color.  The grays are the connection flags (or what I hope to be able to flag the connection points on).  Each time there is a brown line is a new "set" of mostly the same data (only different Product ID).  Each black right boarder is a new part of the database.  If I could some how get Tableau to connect three columns based off that flag to create one line that would be nice, or if I could get Tableau to include values of those nulls back with their other tie ins based off their dest type.     

                     I'm sorry if this has been too abstracted to really be able to help, but my hope is I can learn more about the Data connection to be able to have more control over Tableau.  So the underlying data isn't as important to me as the ability to connect all these in a very specific way.  Which leads back to my original question of "Is there a way to conditionally join two data sets?"  And in this set there are a few flags that could be used, but "ProductID" or "Dest Type" are the best bets for me.

                 

                     If I could create a calculated join field where it states "IF Dest Type = 3 THEN DestinationID END" connected to the original connection (Hopefully producing where it will ONLY join when dest type is 3).  Then doing the same thing on another join (From Table A to Table C instead of B) saying "IF Dest Type = 1 THEN DestinationID END" (Again hopefully making it so it will only create the join if the condition is true).  Unfortunately when I tried this method it seems to still produce the same data on that first calculated join.

                 

                Thanks!

                • 6. Re: Multiple Condition Data Joins
                  Chris McClellan

                  Sorry, I sort of understand the problem , but I don't understand what fields are from what tables.

                   

                  Are you able to create separate CSVs for each table ? (like in the first diagram you posted).

                   

                  Also, what version of Tableau are you using ?

                  • 7. Re: Multiple Condition Data Joins
                    Randy Demaree

                    I broke it down into different Sheets in the same excel, hopefully that will help illustrate the point better.