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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
QlikV1
Contributor II
Contributor II

How to create a script priority flag based on today's date?

Hi,

I have an incident management dashboard and would like to create a new priority flag/field (Low, Medium, High) based on the incident state and today's date. I already use count calculations in the front-end to create my Low, Medium, High expressions (see below), however, need to translate this into script (back-end) language.

Priority Calculations:

Low:  =Count({$<incident_state={'New','In Progress'},opened_at={">$(=date(Today()-1))"}>}number)

Medium: =Count({$<incident_state={'New','In Progress'},opened_at={">=$(=date(Today()-7))<$(=date(Today()-1))"}>}number)

High: =Count({$<incident_state={'New','In Progress'},opened_at={"<$(=date(Today()-7))"}>}number)

Note: a priority field is already existing, however, currently not used. A new field could be created or the existing values in the priority field overwritten.

Labels (2)
1 Solution

Accepted Solutions
QFabian
MVP
MVP

Hi, create a new field, with the difference between dates :

today() - opened_at  as Days

 

and then calculate the Priority using that new field

example : 

 


Load
    *,
    if(Days>7, 'High',
   if(Days >= 1 and Days<=7, 'Medium', 'Low')) as Priority;

LOAD

    number,
   [Incident state],
   opened_at,
   today() - opened_at  as Days
FROM your source;

 

This is load precedent feature!!

Greetings!! Fabián Quezada (QFabian)
did it work for you? give like and mark the solution as accepted.

View solution in original post

4 Replies
Taoufiq_Zarra

@QlikV1  can you share a sample data and the expected output ?

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
QlikV1
Contributor II
Contributor II
Author

was just working on it..column A, B & C are already in the application. Column D (priority) is to be generated (dynamically) based on current dates/incident states. See below example

ABCD
numberIncident stateopened_atpriority
SINC0079884NewToday 05-NOV-20Low
SINC0081102In ProgressYesterday 04-NOV-20Low
SINC0093197In Progress03-NOV-20Medium
SINC0094047New03-NOV-20Medium
SINC0094325New02-NOV-20Medium
SINC0094812In Progress29-Oct-20Medium
SINC0095103In Progress28-Oct-20High
SINC0095659In Progress20-Oct-20High
SINC0096096In Progress20-Oct-20High
SINC0096186New21-Oct-20High
SINC0096685New19-Oct-20High

 

Please let me know if you need anything else

QFabian
MVP
MVP

Hi, create a new field, with the difference between dates :

today() - opened_at  as Days

 

and then calculate the Priority using that new field

example : 

 


Load
    *,
    if(Days>7, 'High',
   if(Days >= 1 and Days<=7, 'Medium', 'Low')) as Priority;

LOAD

    number,
   [Incident state],
   opened_at,
   today() - opened_at  as Days
FROM your source;

 

This is load precedent feature!!

Greetings!! Fabián Quezada (QFabian)
did it work for you? give like and mark the solution as accepted.
QlikV1
Contributor II
Contributor II
Author

Thanks, QFabian! Much appreciated!