Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Qlik_Enthu
Creator II
Creator II

Highlighting Color for a table value based on timestamp differences

Hi All,

I wanted to calculate the difference between two timestamps (one being current time and another from the latest data refresh) and based on the value and source system, should make the column of the latest data refresh timestamp highlighted in red (for delay) or green (for normal).

Tried different calculations and if loops but doesnt seems to work right.

anyone could help?

Labels (1)
4 Replies
eliran
Creator III
Creator III

Hi,

 

Where are you trying to calculate it? script or UI?

Should be prety straight forward, do you have some sample data, or would like to share the code you used?

take a look at this simple example that will work for you:

if(now()-now()-2/24<0,Red(),Green())

Now change the Now() and the Now()-2/24 with your timestamps, and that's it.

 

Eliran.

Qlik_Enthu
Creator II
Creator II
Author

Hi, In the UI inside the Data-->Background color expression..

Sample code fyr!  (along with this the same code should work for diff time delays as well)

IF TimeStamp(Now()) > (EVENT_TIMESTAMP + (2/24))

THEN

Red()

ELSE

Green()

Qlik_Enthu
Creator II
Creator II
Author

Hi Eliran,

I have slightly modified your code and implemented as below. It works fine. However, I try adding two more Source Systems with  a list in if condition and it is not working. Gave the combined condition code as well below. Could you please tell me where i went wrong?

If(SOURCE_SYS = 'A' AND (Timestamp(now())-EVENT_TIMESTAMP>2/24),Red()) -- working fine

If(SOURCE_SYS IN ('A','B','C'),
IF(Timestamp(now())-EVENT_TIMESTAMP>2/24) OR (Timestamp(now())-EVENT_TIMESTAMP>3/24),Red())  -- not working. here B and C both have same delay thresold of 3 hrs.

Qlik_Enthu
Creator II
Creator II
Author

Hi Eliran,

 

USed below code and it works now. 

 

If(SOURCE_SYS = 'A' AND (Timestamp(now())-EVENT_TIMESTAMP>2/24),Red(),
If(SOURCE_SYS = 'B' AND (Timestamp(now())-EVENT_TIMESTAMP>3/24),Red(),
If(SOURCE_SYS = 'C' AND (Timestamp(now())-EVENT_TIMESTAMP>3/24),Red())))

 

Thanks much!!