6 Replies Latest reply on Sep 14, 2017 8:50 AM by Shinichiro Murakami

    Slope Charts

    Rahul Singh

      Hi All,
      I have a question regarding slope charts. Lets say I have created the following slope chart in tableau using Sample Super Store data:

      Now what I need is to color the lines in two colors . One color say green for Sub Categories whose profit increases and red for all the sub categories whose profit decreases.

       

      Any help would be appreciated.

      Thanks

      Rahul Singh

        • 1. Re: Slope Charts
          Simon Runc

          hi Rahul,

           

          So one way to do this is using LoDs...I created the following LoD calculation to work out the difference in profit from one year to the next (btw I've used MAX Year and MAX Year -1, with the Year Filter as context, so it will work with any 2 years selected)

           

          [Profit +/-]

          {FIXED [Sub-Category]: SUM(IIF([Order Date Year] = {MAX([Order Date Year])},[Profit],NULL))}

          -

          {FIXED [Sub-Category]: SUM(IIF([Order Date Year] = {MAX([Order Date Year])}-1,[Profit],NULL))}

           

          I then bring this onto colour and set up as...

           

           

          For my own indulgence I also added Year to size to get that extra feeling of direction!

           

          There is also a way with Table Calcs, but it's more complicated (although less "hard coded")

           

          Hope that helps

          1 of 1 people found this helpful
          • 2. Re: Slope Charts
            Shinichiro Murakami

            Simon was faster.

             

            Or just one path.

            And don't forget to change the filters to "context".

             

             

            Thanks,

            Shin

            2 of 2 people found this helpful
            • 3. Re: Slope Charts
              Rahul Singh

              Thanks a lot Shin and Simon.
              I sometimes pity myself ,when will be I able to write such complex calculations

               

               

              Thanks again.
              Cheers.

              • 4. Re: Slope Charts
                Shinichiro Murakami

                Hi Rahul

                 

                Don't worry.

                Both Simon and I were lazy to skip the step by step formula creation, because we already knew answer for typical questions.

                Actually the formula is long, but not so much "complex".

                I hope you can break down the formula to 4 or more and you understand the steps/logic better.

                 

                Thanks,

                Shin

                • 5. Re: Slope Charts
                  Rahul Singh

                  Hi All,
                  I did something without using LOD's and its working.
                  Created two different measure for 2014 profit and 2015 profit as under :

                  Similarly for Profit 2015 . Then I created a measure for difference :

                   

                  Dragged this into color marks and my job was done without any calculations.:)

                   

                   

                   

                   

                   

                  Thanks,
                  Rahul Singh

                  • 6. Re: Slope Charts
                    Shinichiro Murakami

                    Rahul,

                     

                    Good job.

                    It definitely works in this specific case.

                    Ours(LOD) will cover the case when you have 3 or more years and want to filter it to two.

                     

                    Thanks,

                    Shin