0 Replies Latest reply on Oct 10, 2018 9:44 AM by Marcus Bright

    SQL/Tableau Query for Interactive Dashboard

    Marcus Bright

      Hi Forum,

       

      Hoping you can help me with a request I have had come through for a Tableau viz. The basis of it is that I’ve been given 3 different tables and a mock-up chart of how the output should look.

       

      Reference Tables:

       

      ID            Regional Code

      1              KF1

      1              KF2

      2              KF3

      3              KF4

                     

      ID            County

      1              Dorset

      2              Somerset

      3              Gloucestershire

                     

      Main Table –

                     

      Category              Regional Code   Price

      Category1           KF1                         -

      Category2           KF1                         -

      Category3           KF2                         -

      Category4           KF2                         -

      Category5           KF2                         -

      Category6           KF3                         -

      Category7           KF4                         -

       

      What they want is to be able to have a bar chart in Tableau that will show a specific category from the Main Table as well as a specific county which is then then split by the cost of activity both ‘Inside’ and ‘Outside’ a county…with options to then allow end-users to be able to switch the category and county.

       

      I’m not entirely sure what the best way to approach this is and so far my queries have not worked, to get it at least working I’ve thought about creating a column via SQL for each county based on the 2nd reference table, i.e.

      ‘CASE WHEN Regional Code in ('KF1',’KF2') THEN 'Within County'

      ELSE 'Outside Count'

      END AS 'Dorset’

       

      This is very inefficient however, and I also have the issue that the Regional Codes can and will change which county they come under so it needs to be dynamic. 

       

      Any ideas?

       

      Kind Regards,

       

      Marcus