42 Replies Latest reply: May 16, 2017 8:31 AM by ishan Bhatt RSS

    color by expression - QlikSense

    Philipp Wesseling

      Hi all,

       

      i am struggeling with a simple line chart. It shows revenue over month - so "Month" would be one dimension. It has two expressions. The one calculates revenue for the current year. The other calculates revenue for the previous year. All no problem.

       

      What i want - and until now couldnt get to: I want the line representing the current year to have a specific color (lets say, red) and the line representing the previous year to have another specific color (lets say, gray).

       

      Can anyone help and explain how this can be done in SENSE ?

       

      Thanks!

      K

        • Re: color by expression - QlikSense
          Sean Donovan

          Hi Philipp,

           

          Left-click the line chart while in edit mode.  The properties of the chart will show up on the right side of your screen.  Click on Appearance --> Colors and legend --> And deselect the option where it says auto colors ON.  Select "By expression" in the menu box that appears, and underneath that you can enter in a expression that can customize the color of the line chart.

           

          Example:

          IF(YearField = '2012', Red(), Green())

           

          Cheers,

          Sean

            • Re: Re: color by expression - QlikSense
              Philipp Wesseling

              Thanks Sean.

               

              Unfortunately this does not seem to do the job, as my dimension "Month" is not unique to a year. So if i set an expression like you suggested, it does not do anything in the chart...

              • Re: color by expression - QlikSense
                Haikuo Yu

                Hi Sean,

                I also have a similar problem about color by expression with QlikSense.

                I use the following expression to assign different color to each REGION (REGION column contains ‘West’, ‘East’, ‘North’, ‘South’)on the map, but my problem is how to also show a legend with REGION type and the corresponding color.

                By the way, I can not use REGION as my map dimension, because I have to use another column (State, State column contains different states name) as my map dimension.

                Could you please give any suggestion?

                Thanks so much for your help!

                 

                If ( REGION = 'West', red(),

                      If ( REGION = 'East', green(),

                           (

                            if ( REGION = 'North', blue(), Yellow() )   

                           )

                      )

                )

              • Re: color by expression - QlikSense
                Stephen Street

                Hi, I've seen a few issues around applying specific colours to charts in Sense and wanted to offer an alternative solution. This works well if there are a limited number of dimensions you want to display (e.g. last four years data with each year coloured in gradients of gray with the current year in red, or sales broken down by product category with a total sales amount also displayed in specific colours)

                This can be achieved using a synthetic dimension

                ColorTestSyntheticDim.JPG.jpg

                 

                1. Create the dimension as a synthetic dimension using ValueList. Note: define the dimensions using a useful reference (e.g. 'Current Year') rather than 'Dim1' since this will be displayed in the popups!

                =ValueList('Dim1', 'Dim2', 'Dim3', 'Dim4')

                 

                2. Create a single measure with the value to be shown for each Dimension

                if(  ValueList('Dim1', 'Dim2', 'Dim3', 'Dim4')='Dim1', SUM({<Year={2011}>}Sales),

                if(  ValueList('Dim1', 'Dim2', 'Dim3', 'Dim4')='Dim2', SUM({<Year={2012}>}Sales),

                if(  ValueList('Dim1', 'Dim2', 'Dim3', 'Dim4')='Dim3', SUM({<Year={2013}>}Sales),

                if(  ValueList('Dim1', 'Dim2', 'Dim3', 'Dim4')='Dim4', SUM({<Year={2014}>}Sales)

                ))))

                 

                3. Set Color by Expression with the colours you want allocated to each Dimension

                if(  ValueList('Dim1', 'Dim2', 'Dim3', 'Dim4')='Dim1', argb(80,80,80,80),

                if(  ValueList('Dim1', 'Dim2', 'Dim3', 'Dim4')='Dim2', argb(160,80,80,80),

                if(  ValueList('Dim1', 'Dim2', 'Dim3', 'Dim4')='Dim3', argb(220,80,80,80),

                if(  ValueList('Dim1', 'Dim2', 'Dim3', 'Dim4')='Dim4', lightred()

                ))))

                 

                I've attached an application enhancing Josh Good's example. I hope this proves useful.

                • Re: color by expression - QlikSense
                  Vicio Giglio

                  I read all this long thread. Powerless, I chose for a google search with recent results, and I found the right thread.

                   

                  Color scheme in qliksense for bar chart

                   

                  That works well for me. If you believe that is the correct answer to this thread, please mark this reply as the solution, and we can help newcomers from reading all this thread.

                  • Re: color by expression - QlikSense
                    ishan Bhatt

                    Hi Philipp,

                     

                    In Qlik Sense new release provide this type of functionality to give a specific color to the specific measure.

                     

                    Please see my answer in below link for more detail.

                     

                    https://community.qlik.com/message/1267037?et=watches.email.thread#1267037

                     

                    Hope this will help.

                    • Re: color by expression - QlikSense
                      ishan Bhatt

                      Hi Philipp,

                       

                      In the New version of the Qlik Sense ( i.e 3.2 SR1), it is possible to give a specific color to the multiple expressions (Measures).

                       

                      I've given a different color in example attached by you in this blog and below is the resulting image.

                      Chart.PNG

                      To give a specific color to measure follow below steps:

                       

                      1. Make Expression as Master Item (Measures).

                      2. In Master Item (Measures) Choose Specific Color for that expression.

                      3.Apply that Master Item Measure directly into Chart Measures.

                       

                      Below are the Images for the Master Item Setting.

                      Master Item.PNG

                      Master Item Detail.PNG

                       

                      Now use this Master Measure Item in Your Measure.