2 Replies Latest reply on Jun 29, 2016 10:37 AM by J Jack

    Sales by previous year and current year

    J Jack

      Hello All,

       

      i have two columns, one for sales (measure)and the the other column name 'Week'(dimension) has values like, from 201501,201502...201552 till  201601...201618.201619.., it is like sales by week. So, I have to separate the sales for 2015 i.e from 201501-201552(new column) and the sales for 2016 i.e from 201601-201620 which is current week (new column).

       

      Any suggestion would be helpful.

       

      J

        • 1. Re: Sales by previous year and current year
          Vincent Baumel

          It sounds like you need a calculation that splits off the final two characters of your dimension field. This would give you a separation of year and week. Here's how I mocked it up:

           

          • Created an excel spreadsheet with a column labeled Week and rows ranging from 201501-201652, turning around from 201552 to 201601, and a column labeled Sales with randomized data for each row
          • Connected to the spreadsheet in Tableau
          • Converted the Week field from numeric to string
          • Created a calculation field called Year that reads like this:     LEFT([Week], 4)
          • Created a calculation field called WeekNumber that reads like this:    RIGHT([Week], 2)
          • Switching over to Sheet 1, drag WeekNumber onto Year to create a hierarchy
          • Drag the "Year, Week" hierarchy to the Rows shelf, and Sales to the Columns shelf

           

          Now you can drill in and explore your data!  Let me know if this helps.

           

          Data.PNG                  Sheet.PNG

          • 2. Re: Sales by previous year and current year
            J Jack

            Thanks a  lot ! I don't want to separate the week, but I got the logic !

             

            J