3 Replies Latest reply on Oct 17, 2013 6:08 AM by Deb Brisson

    Writing SQL in Tableau vs connecting to a table

    Deb Brisson

      I have sort of a general question about Tableau.


      I wrote a query that returned the result set I needed. The data looked fine when I looked at it using "View Data" in Tableau. But when I tried to count the records for a group, instead if returning the number 350, it returned the number 1, 350 times (just a whoooooole bunch of 1s). I spent a lot of time playing with all the fields, reorganizing the pills, creating calculated fields, changing the way things were calculate, but to no avail.


      As a test, I used the same exact query to insert the same data into a permanent table in my sql database. When I connect to the table and do the same grouping, the count works fine.


      Is there some kind of known issue at play here? I would rather write queries than create a table for every single report I need to do. Is there a difference between a dataset you get from a query and one you get from just connecting to a table?



        • 1. Re: Writing SQL in Tableau vs connecting to a table
          Robert Morton

          Hi Deb,


          Are you using that query in a Custom SQL connection? Could you paste that query here so we can look for possible problems?


          Note that if you are using RAWSQL calculated fields, you will have very limited success trying to express an entire SELECT statement within the RAWSQL formula. If that's really what you're after then you should change your connection to a Custom SQL connection and place your query there.



          1 of 1 people found this helpful
          • 2. Re: Writing SQL in Tableau vs connecting to a table
            Ramon Martinez

            Hi Deb,


            It is difficult to help you without having more information about your scenario. As Robert Morton mentioned in his post, we need to know first if your are using your query in a Custom SQL connection and to have an idea of that query.

            Can you provide the query and a package workbook with a sample (extracted) data set?


            Assuming you connect to your data source using a Custom SQL connection, please verify if option Aggregated Measures is checked in the Analysis menu. By your comment it seems that option is unchecked.


            If Aggregated Measure is checked, verify if you have a dimension in level of detail and make sure you are counting the records using the function SUM([Number of Records])


            Again, it is easier for us if you provide a workbook.




            • 3. Re: Writing SQL in Tableau vs connecting to a table
              Deb Brisson

              Nice!! I didn't know about the Aggregated Measures in the Analysis menu. That's exactly what it was. Thank you so much. I wish I had asked earlier on rather than making my self insane. Funny, the difference between hours of clicking the wrong button and a millisecond of clicking the right one.


              I was going to try to create a simple test so I could past a workbook. I'll be sure to do that when possible to make it easier to get help.


              Thanks again!