-1

New Qlik Sense/ Qlik View user here.

I want to create a KPI, where the conditional coloring will filter based on two fields:

  1. EstArrivalTimeHrMinSec [Estimated time taken for an Ambulance to arrive at Incident scene (Predicted time)]

  2. TimeTakenforAmbulancetoArrive [Actual time taken for an Ambulance to arrive at Incident scene (Actual time)]

These two fields (fieldnames are in italics) are both formatted in Time('mm:ss') format for comparison, and I basically want to calculate:

  • If Actual time taken < Estimated time taken

then I want the KPI to be displayed in GREEN (actual time for the ambulance to arrive is earlier than predicted, which is GOOD).

  • If Actual time taken > Estimated time taken

then I want the KPI to be displayed in RED(actual time taken is later than predicted, which is BAD).

I have already tried creating a conditional coloring in a KPI object on my own, and here is my expression:

=If(Time(avg({$}TimeTakenforAmbulancetoArrive), 'mm:ss') < Time(avg({$}EstArrivalTimeHrMinSec), 'mm:ss'), Time(avg({$}TimeTakenforAmbulancetoArrive), 'mm:ss'), Time(avg({$}EstArrivalTimeHrMinSec), 'mm:ss'))

Sometimes the conditional coloring will work, sometimes it wouldn't, and I don't know what exactly I'm doing incorrectly with my expression. I have attached a snapshot below regarding the issue.

When the expression sometimes works (time displayed correctly as GREEN)

Time displayed Correctly

When the expression doesn't work (time should display as GREEN instead of RED)

Time displayed Incorrectly

Please help! Thanks in advance.

Christoph
  • 23
  • 4

1 Answers1

0

I think your expression is more complicated than it should be. The conditional color will compare the value on the KPI with the reference you add on this expression.

If your showing the TimeTakenforAmbulancetoArrive metric, you should simply add here an expression like Time(avg({$}EstArrivalTimeHrMinSec), 'mm:ss').

BrunoMarques
  • 557
  • 2
  • 11
  • In the KPI box I highlighted, I just want to show if actual time taken < predicted time taken, the time will automatically display in green; and if actual time taken > predicted time taken, then it will display in red. I tried just simply writing the expression you wrote, and the color doesn't update dynamically. The expression I wrote somehow seems to work now, I'll let you know if I have any further issues. Thanks for your help – Christoph Nov 24 '17 at 02:12