1 Reply Latest reply: Feb 23, 2018 4:34 PM by Juraj Misina RSS

    Counting oldest record with variables in a KPI

    Ryan Reid



      I am trying to count from a DB the oldest record by the date that meets certain criteria.  Currently, I can use the below expression to count the total number of seats and it works with no issue:


      Count(If(Aggr(NODISTINCT Max(ActDateStamp), [RefreshSRDetail.SMTicket]) = ActDateStamp and [Status] = 'Closed', [RefreshSRDetail.SMTicket])) 


      My issue is that I need to then add additional criteria to the count, but it does not recognise the additional variables.  Below is the example of the code I am using to do this:


      Count(If(Aggr(NODISTINCT Max(ActDateStamp), [RefreshSRDetail.SMTicket]) = ActDateStamp and [Status] <> 'Closed' and [Activity] = '*DepH*', [RefreshSRDetail.SMTicket])) 


      The additional 'And [Activity] = '*DepH*' is not being included in the calculation.  I am very new to Qlik, so not sure if this is the just incorrect formatting of the expression or something Qlik is not able to do.  Appreciate any feedback or suggestions!