12 Replies Latest reply on Mar 20, 2017 5:12 AM by Scott Dexter

    Change Background Color

    Scott Dexter

      From the sheet below I am trying to get the green area to change from green to red in the event a condition is not met. I.E. If the Mac Margin Percent > KPI Value then 'Green' ELSE 'Red' END is the formula I am using but it doesn't seem to change the color if I change the data or if I change the > to < which it should as that is how I test it. Now I know Count distinct is not the correct aggregation to use here but when I change off of it everything goes white. so I am at a loss here. I am new to tableau and am completely self taught, if you have a simple explanation as to what I should do here please let me know. This is probably something very simple.

       

       

        • 1. Re: Change Background Color
          Deepak Rai

          Hi Scott,

          See the Screenshots, It Changes Color based upon your Values.

          MMP>KPI is RED

           

           

          MMP<KPI is Green

           

           

          Hope it Helps!!!

          Thanks

          Deepak

          • 2. Re: Change Background Color
            Scott Dexter

            Deepak, I appreciate you taking the time to look into my question, your answer however is beyond me. I have no idea what you mean with this, if you could send the workbook back with the solution I can diagnose how to re-create your proposed answer. When I change KPI Color it does nothing in my sheet, not to mention I don't understand even remotely how this could possibly work and be flexible enough to take changing values over time as our goals are put together by month and the performance is measured the same way.

             

            Thank you,

             

            Scott

            • 3. Re: Change Background Color
              Deepak Rai

              Hi Scott,

              The calculation KPI Color would act to change colors in view based upon the result of Calculation. Try changing your values , it will change color. My Solution is in 10.2. and is attached.

              thanks

              Deepak

              • 4. Re: Change Background Color
                Scott Dexter

                Deepak, I am unable to open your version as it is in 10.2 and I am using 10.1 as I said before I am a complete novice so seeing things is highly advantageous to me. I have used other packages just not tableau and it behaves much differently than other applications I have used in the past to do BI reporting with. Now, When I change the formula I can get it to change to red, but I when I flip the arrow it does not change to another color, it stays the same. See attached. Please elaborate on what other thing you might have changed.

                • 5. Re: Change Background Color
                  Kaz Shakir

                  Scott,

                  Part of the problem you are facing is that you are converting your If statement into a number using the FLOAT function.  And since Tableau doesn't have a value of "Green" and "Red" both of those are getting the value 0 - and that's the green color on your scale (in the right hand corner).

                   

                  You could change your KPIColor calculated field to be something as simple as this:

                   

                  KPIColor

                  [Mac Margin Percent] < [KPI Value]

                   

                  And then you will notice that it's no longer a measure, but is now a True-False type dimension.  You can place this on the Color tile on the Marks shelf, and then adjust the colors for True and False to get the colors you want.  Note: that you will need to change your KPI value to get it to switch from False to True in order to set the color for both.

                   

                  Hope that helps.  Please let us know if that addresses your goal.

                  Kaz.

                  • 6. Re: Change Background Color
                    Deepak Rai

                    Hi Scott,

                    Use this Calculation for KPIColor:

                     

                    IF [Mac Margin Percent] < [KPI Value] THEN 'Green' ELSE 'Red' END

                     

                    and you would get this,because your Condition is FALSE and Mac MARGIN is Greater than KPI value.

                     

                     

                    and to Check if it works when KPICOLOR formula returns TRUE, I changed Mac Margin to 0.1 so it is 10% which is less than 18.10% so now it will change color to GREEN. This would happen dynamically in your data. Just Drag the Calculation KPICOLOR to Color and dont use CNTD.

                     

                    That's it.

                    Let me know if it Helps!!!

                    Thanks

                    Deepak

                    • 7. Re: Change Background Color
                      Scott Dexter

                      Ok we are getting somewhere with this, however, I have no color palette that specifies true false. Like I said, I am a novice do not assume I know anything... I selected traffic light and used

                      IF [Mac Margin Percent] < [KPI Value] THEN 'Green' ELSE 'Red' END and it turned it Yellow

                      Then I changed it to automatic and it changed it to blue and red by changing the arrow.

                      IF [Mac Margin Percent] < [KPI Value] THEN 'Green' ELSE 'Red' END = Blue

                      IF [Mac Margin Percent] > [KPI Value] THEN 'Green' ELSE 'Red' END = Red

                      and that doesn't seem to work like it should.

                       

                      So I don't know where to take this now.

                       

                      Thank you,

                       

                      Scott

                      • 8. Re: Change Background Color
                        Scott Dexter

                        This is how green turns out because I don't know how to deal with the color. Now Deepak, I couldn't get this to work before to any degree because my KPIColor was a measure not a dimension, which is as it appears here. That is a part of the process that was not explained. Thank you for showing that to me, however, not I can't get the colors I want because I don't know how to do that. How do I change the colors? Everything I have tried in the 1st (MIN(NumberOfRows) doesn't seem to do anything with 2 colors other than colors I do not want to use.

                         

                        • 9. Re: Change Background Color
                          Deepak Rai

                          Scott,

                          If you follow thescreenshots , you would see it is already solved. Do it either way, once you get a color in view. Just go to edit color and specify. Next time it would be automatic based upon your condition.

                          Thanks

                          Deepak

                          • 10. Re: Change Background Color
                            Deepak Rai

                            Hi Scott,

                            I changed my Workbook to 9.2. Please open it and let me know.

                            Thanks

                            Deepak

                            • 11. Re: Change Background Color
                              Kaz Shakir

                              Scott,

                              You should be able to see Depak's solution with his last attachment.  It's a good one, so you should be able to follow that.

                               

                              In case, you have trouble with it, here are the screen shots for an alternative:

                               

                              1. Change your formula in the KPIColor formula:

                               

                              2. Remove the CNTD(KPIColor) from the Marks shelf, and replace with the new KPIColor pill:

                               

                              3. Click the Color tile to open the menu, and click Edit Colors, and then on the Select Color Palette, choose Traffic Light:

                               

                              4. Then on the "Select Data Item" side click on False, and then on the color palette side click on one of the red squares:

                               

                              5. When you click OK or Apply, it will change the color of your chart.  Now you need to set the color for the true option, in the same way.  First you have to change your formula in the KPIColor field so that it produces a true result - simply flip the "<" to a ">" and then follow steps 3 - 5 again, this time choosing a green color for the true.

                               

                              At that point you will need to change your formula in KPIColor back again, and then whenever you change either the values in Key Performance Indicator or Mac Margin Percent, the chart should reflect the correct color.

                              • 12. Re: Change Background Color
                                Scott Dexter

                                Kaz, your explanation here is exactly what I needed, while Deepak might have solved the issue, I could not follow as I did not know about how to change the colors on True and False. Like I said in the first post, I am a complete novice and your steps provided what I needed to ensure each of the bases is covered. Deepak did answer the question but I simply do not have the experience to follow when I had not done Tableau reports before. I would have never thought I would have had to do this. Now I know. Thanks again so much! This has been a huge help!