7 Replies Latest reply on Oct 8, 2018 5:43 PM by Ken Flerlage

    Datasource Joins based on  the conditions

    Sami N



      i have hit upon a problem and it is not a unique one .


      i have an operational  data table with measures and dimensions (for eg.online sales person , inhouse salesperson) from table U  and i am connecting this data to a external data source which hosts the  information of sales people( name , office, region,,id) from table X


      while joining in the datasource tab i use the U.OnlineSalesPersonId = X.id to join

      but the reporting need is aa bit complex   as there are conditions based on the time of the sale , region and the type of product  when we have a time not between 11 and 6 am and region is within UK and  product is ABC then the join should be on InHouseSalesPersonId


      any ideas how to achieve this

        • 1. Re: Datasource Joins based on  the conditions
          Ken Flerlage

          At a high-level, there are a couple of different solutions:


          1) Perform Some Data Prep - Ideally, you'd perform some upfront data prep before joining in Tableau. If you have existing tools for this, great. Otherwise, check out Tableau Prep. Ultimately, you just want to structure the data in a way that makes it easier to bring everything together.

          2) Use Join Calculations - If, for some reason, the above is not an option, then you could create join calculations to allow you to perform the logical operations before performing the join.


          If you could provide a sample of your data, we could provide a more detailed answer.

          • 2. Re: Datasource Joins based on  the conditions
            nikher verma

            Hi Sami N ,


            You need to add filter at time of joining data source .It can be done easily .


            Click on add filters next to connection ,you will get a pop-up then click on add & you will get the names of attributes on which you want to apply filter. you can have multiple filters as per your requirement .



            -Nikher Verma

            Please mark it right and helpful if this serves your purpose so that others can also get benefited & also to close the thread.

            • 3. Re: Datasource Joins based on  the conditions
              Sami N

              I think the question is not clearly understood.


              To make it clearer, have an attachment of made up data



              I have two columns


              inspecting agent and

              servicing agent


              I need to show the sales by region  for inspecting sales and servicing sales

              for a start i connect the tables as follows


              agent sales .inspecting agent= agent details.agent name


              Cool i get the inspecting sales by region


              But when it comes to servicing sales by region the join has to be on

              agent sales .servicing agent = agent details.agent name

              so that i get the region of the servicing agent


              like for e.g

              Inspecting agent    servicing agent    Visitid    date    value      sales    unit

              hellman                      larkins              796809      01/10/2018    883      24



              details of agent details

              hellman    - office = bristol    - region = gloucester

              larkins      - office = Edinburgh    - Region = ayr


              the row of data above will show the region as gloucester for the servicing agent without the right join.


              any ideas on doing a condition based join ??

              • 4. Re: Datasource Joins based on  the conditions
                Ken Flerlage

                For that one sample record, what is the end result you're looking for?

                • 5. Re: Datasource Joins based on  the conditions
                  Sami N

                  i would like to show the sales value by inspecting agent  region and sales value by servicing agent region

                  i would like to say region Gloucester to have 883 sales value  for inspecting and  883 value  for Ayr for servicing.

                  • 6. Re: Datasource Joins based on  the conditions
                    Ken Flerlage

                    Got it. So I think you just need to add your agent table twice and join one on inspecting agent and one on servicing agent.


                    Start by adding the sales table and agent table and joining them based on the inspecting agent.

                    Then add the agent table again. This time, join based on the servicing agent.

                    You'll now have two separate sets of agent information, one for inspecting and one for servicing:

                    To reduce confusion, I'd rename these fields as follows:

                    Then you can build your inspecting view:

                    and your servicing view:

                    See attached workbook.


                    If this solves your problem, please be so kind as to mark this as the "correct answer." This will allow us to close this thread and will also make it easier for people to find the answer if they have similar questions in the future. Thanks!

                    • 7. Re: Datasource Joins based on  the conditions
                      Ken Flerlage

                      Hi, just following up on this one. Let us know if we can be of any further assistance.