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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Criteria on load Calculation

Hi I am trying to create a calculation with criteria,

I want to calculate the time difference from Application to any other Status in the New Status filed. The catch is that I only want this to be done if the original old status is NULL. I would like delta to be in day hour month second time frame.

Unique IDStatusChangeDateOld Status DescriptionNew Status Description
2136:45.7NULLApplication
2146:51.5Application Active
2147:08.6Active Inactive
6152:47.9NULLPending
6130:14.4Pending Active
6100:00.0Active Active with
  Audit

Best!

10 Replies
Anonymous
Not applicable
Author

Hi All,

For some reason all suggestions that I have received have not worked, but I very much appreciate everyone's advice and suggestions.

I tried another method, creating flags and time differentials for each of the possible paths(Status Changes) that a UID could take after the initial criteria of going from null to application. I am still missing something in the scripting that will not give me what I am looking for on the front end. I have listed the code below for reference and/or suggestions.

  1. NULLASVALUE OldStatusID;
  2. StatusDescription_Map:
  3. Mapping LOAD ID,
  4.     Description;
  5. SQL SELECT *
  6. FROM MYTABLE;
  7. ChangeHistory:
  8. LOAD TravelerID,
  9.     CompanyID,
  10.     TravelerID & ' ' & CompanyID as UID,
  11.     ChangeHistoryID as CID,
  12.     StatusChangedByUserID,
  13.     StatusChangeDate,
  14.     OldStatusID,
  15.     if(isnull([OldStatusID]),'NULL', [OldStatusID]) AS [Old Status],
  16.     NewStatusID,
  17.     ApplyMap('StatusDescription_Map',NewStatusID) AS [New Status Description],
  18.     ApplyMap('StatusDescription_Map',OldStatusID, 'Null') AS [Old Status Description],
  19.     timestamp(StatusChangeDate) as CleanStatusChangeDate,
  20.     Date(Floor(StatusChangeDate), 'M/D/YYYY') as DateKey,
  21.     Timestamp;
  22. SQL SELECT *
  23. FROM MYTABLE1
  24. WHERE [StatusChangeDate]>= '01/01/2015'
  25. ;
  26. NoConcatenate
  27. ChangeHistory1:
  28. LOAD RowNo() as RowNum, *;
  29. LOAD *
  30. Resident ChangeHistory
  31. Order by UID, StatusChangeDate;
  32. NoConcatenate
  33. ChangeHistory2:
  34. Load *,
  35.      if([New Status Description] = 'Active',
  36.         if(Peek(UID, -1) = UID, if(Peek([New Status Description], -1)= 'Application', 1,
  37.            if(Peek(UID, -2) = UID, 1, 0))),0) as Move_To_Active,
  38.      if([New Status Description] = 'Active',
  39.         if(Peek(UID, -1) = UID, if(Peek([New Status Description], -1)= 'Application', Interval(StatusChangeDate - Peek(StatusChangeDate, -1), 'hh:mm'),
  40.            if(Peek(UID, -2) = UID, Interval(StatusChangeDate - Peek(StatusChangeDate, -2), 'hh:mm'), 0))),0) as [Hours Application to Active],
  41.      if([New Status Description] = 'Active with Audit',
  42.         if(Peek(UID, -1) = UID, if(Peek([New Status Description], -1)= 'Application', 1,
  43.            if(Peek(UID, -2) = UID, 1, 0))),0) as Move_To_Active_with_Audit,
  44.      if([New Status Description] = 'Active with Audit',
  45.         if(Peek(UID, -1) = UID, if(Peek([New Status Description], -1)= 'Application', Interval(StatusChangeDate - Peek(StatusChangeDate, -1), 'hh:mm'),
  46.            if(Peek(UID, -2) = UID, Interval(StatusChangeDate - Peek(StatusChangeDate, -2), 'hh:mm'), 0))),0) as [Hours Application to Active with Audit],
  47.      if([New Status Description] = 'Holding',
  48.         if(Peek(UID, -1) = UID, if(Peek([New Status Description], -1)= 'Application', 1,
  49.            if(Peek(UID, -2) = UID, 1, 0))),0) as Move_To_Holding,
  50.      if([New Status Description] = 'Holding',
  51.         if(Peek(UID, -1) = UID, if(Peek([New Status Description], -1)= 'Application', Interval(StatusChangeDate - Peek(StatusChangeDate, -1), 'hh:mm'),
  52.            if(Peek(UID, -2) = UID, Interval(StatusChangeDate - Peek(StatusChangeDate, -2), 'hh:mm'), 0))),0) as [Hours Application to Holding],
  53.      if([New Status Description] = 'Inactive',
  54.         if(Peek(UID, -1) = UID, if(Peek([New Status Description], -1)= 'Application', 1,
  55.            if(Peek(UID, -2) = UID, 1, 0))),0) as Move_To_Inactive,
  56.      if([New Status Description] = 'Inactive',
  57.         if(Peek(UID, -1) = UID, if(Peek([New Status Description], -1)= 'Application', Interval(StatusChangeDate - Peek(StatusChangeDate, -1), 'hh:mm'),
  58.            if(Peek(UID, -2) = UID, Interval(StatusChangeDate - Peek(StatusChangeDate, -2), 'hh:mm'), 0))),0) as [Hours Application to Inactive],
  59.      if([New Status Description] = 'Inactive with Audit',
  60.         if(Peek(UID, -1) = UID, if(Peek([New Status Description], -1)= 'Application', 1,
  61.            if(Peek(UID, -2) = UID, 1, 0))),0) as Move_To_Inactive_with_Audit,
  62.      if([New Status Description] = 'Inactive with Audit',
  63.         if(Peek(UID, -1) = UID, if(Peek([New Status Description], -1)= 'Application', Interval(StatusChangeDate - Peek(StatusChangeDate, -1), 'hh:mm'),
  64.            if(Peek(UID, -2) = UID, Interval(StatusChangeDate - Peek(StatusChangeDate, -2), 'hh:mm'), 0))),0) as [Hours Application to Inactive with Audit],
  65. if(([Old Status Description] = 'Null') and ([New Status Description] = 'Application'), 1, 0) AS NewApplicationSendFlag
  66. Resident ChangeHistory1;
  67. DROP Table ChangeHistory;
  68. DROP Table ChangeHistory1;

Thank you again for all of the help, Cheers!