Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
FLASH SALE: Save $500! Use code FLASH2026 at checkout until Feb 14th at 11:59PM ET. Register Now!
cancel
Showing results for 
Search instead for 
Did you mean: 
samuel_brierley
Creator
Creator

label expression optimisation

Hi all,

i have a chart with quite a lengthy expression that defines the colour of the bar and i was wondering if it could be optimised,

=if(EquipmentSetting_Id

   = 20, rgb(102,51,0),

    if(EquipmentSetting_Id

    ='30', rgb(255,128,0),

    if(EquipmentSetting_Id

        ='40', rgb(255,255,0),

        if(EquipmentSetting_Id

            ='50', rgb(102,0,102),

                if(EquipmentSetting_Id

                ='60', rgb(0,255,0),

                 if(EquipmentSetting_Id

                  ='98', rgb(255,0,0),

//    if a sign is set at that location then colour the bar accordingly

          

  (if(avg($(vCalc)) = -1,

  rgb(0,0,255), //if no data make blue

  if(vMeasure = 'Speed',

  rgb((255-(255*(avg($(vCalc))/120))),(255-(255*(avg($(vCalc))/120))),(255-(255*(avg($(vCalc))/120)))),

  if(vMeasure = 'Occupancy',

  rgb((255-(255*(avg($(vCalc))/30))),(255-(255*(avg($(vCalc))/30))),(255-(255*(avg($(vCalc))/30)))),

  rgb((255-(255*(avg($(vCalc))/20))),(255-(255*(avg($(vCalc))/20))),(255-(255*(avg($(vCalc))/20))))

// 3 measures based on user selection. Speed, occupancy and flow. these are displayed on a greyscale

))))))))))

not sure if this is needed but to provide a little context to the expression.

i have detectors and signs. the detectors detect speed, flow and occupancy (bottom half) and are displayed on a grayscale on the chart. depending on what the detectors detect signs are set (top half).

the dimension is location so easy to understand that bit.

thanks for any help.

Labels (1)
1 Reply
Anil_Babu_Samineni

How about this?

Pick(Match(EquipmentSetting_Id,'20','30','40','50','60','98'),Red(), Green(), Yellow(), Black(), Blue(), Violet(),

Then Use Expression here Then close parenthesis ")"

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful