2 Replies Latest reply on Jan 24, 2019 4:34 PM by Ken Flerlage

    How to Pivot MSSQL Connected Data?

    Shreyas Talamakki

      I'm trying to use the in-built Pivot feature for Tableau and I realized that it's only available for Excel and Text files, but I'm trying to pivot the table using a MSSQL connection. Can anybody help me figure out how to do this? I'm an intern and pretty new to SQL queries too so I wasn't expecting that Tableau didn't have pivots enabled for SQL connections.

       

      The question is how to pivot a file that's formatted like this:

                

      OrderIDPart # PickingOrderLineIDFulfillmentLocationIDQuantityRequestedQuantitySentPicked ByPacked ByShipped ByPacked DateShippingCreated DateFulfilledDate
      68834248386994779650311Evan ObrienEvan ObrienEvan Obrien1/23/19 6:57 PM1/23/19 7:04 PM1/23/19 6:56 PM
      68814152076992508650353Larry FergColt GrishColt Grish1/23/19 7:19 PM1/23/19 7:20 PM1/23/19 6:29 PM
      68811184756992192650366Larry FergColt GrishColt Grish1/23/19 7:22 PM1/23/19 7:22 PM1/23/19 6:21 PM
      68853083136996671650311Alex TilrayAnna HendrixAnna Hendrix1/23/19 7:48 PM1/23/19 7:49 PM1/23/19 6:47 PM
      68853003126996663650311Alex TilrayAnna HendrixAnna Hendrix1/23/19 7:48 PM1/23/19 7:49 PM1/23/19 6:36 PM
      68834033106994758650344Alex TilrayAnna HendrixAnna Hendrix1/23/19 7:48 PM1/23/19 7:49 PM1/23/19 6:56 PM

       

       

      Into A pivoted table that resembles the above table very much, but just instead of pickedby packedby and shippedby being seperate columns its under one column as name and the respective packed, shipped, or fulfilled dates are complied as one 'Action Date' column?

               

      All ActionsNameQuantity RequestedQuantity Sent Fulfilled DatePackaged DateAction TimeSpecific Action
      Fulfilled ByAnna Hendrix111/16/2019 15:521/16/2019 15:591/16/2019 15:52Picking
      Fulfilled ByAlex Tilray111/16/2019 15:271/16/2019 15:571/16/2019 15:27Picking
      Packages Created ByColt Grish111/16/2019 13:221/16/2019 13:261/16/2019 13:26Packing
      Shipped ByEvan Obrien111/23/19 6:56 PM1/23/19 6:57 PM1/23/19 7:04 PMShipping

       

      Note that I'd like to know how the custom SQL query is set up to make this happen. I tried looking into MSSQL's webpage on pivots but that doesn't seem to be helping and I know the Tableau forums are very responsive and accurate!