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

Count Tickets until Previous Month

Hello,

I have the following table:

ID_TCKTSTATUSYEARMONTH_STATUSCREATE_DATECREATE_TIMEMONTH_CALENDAR
TCKT05In Progress2016Jul15/07/201614:29:33Jul
TCKT05In Progress2016AugJul
TCKT05In Progress2016SepJul
TCKT05Closed2016OctJul
TCKT02In Progress2016May02/05/201619:51:00May
TCKT02In Progress2016JunMay
TCKT02Completed2016JulMay
TCKT02Completed2016AugMay
TCKT02Closed2016SepMay
TCKT03Planned2016May20/05/201602:45:53May
TCKT03Planned2016JunMay
TCKT03Closed2016JulMay

Each ID_TCKT has a CREATE_DATE/CREATE_TIME associated to a Master Calendar by a field MONTH_CALENDAR, so if I choose month = Jul I see TCKT05, if I choose month = May I see TCKT02 and TCKT03. Each ticket appear once, depending on selected month.

The issue is that I need to add the following logic:

If I choose any month, for example, MONTH_CALENDAR = Jun I need to COUNT how many tickets have STATUS <> Closed until the previous month from MONTH_STATUS field, in this case: MONTH_STATUS = May and this is what I should get, by using a Text Object:


- TCKT05: 0 (Because the ticket was Created in Jul)

- TCKT02: 1 (Because the ticket was Closed in Sep)

- TCKT03: 1 (Because the ticket was Closed in Jul)

So the total COUNT would be = 2

Another example, if MONTH_CALENDAR = Aug we have to count tickets with STATUS <> Closed until MONTH_STATUS = Jul:

- TCKT05: 1 (Because the ticket is In Progress in Jul)

- TCKT02: 1 (Because the ticket is Completed in Jul)

- TCKT03: 0 (Because the ticket was Closed in Jul)

So the total COUNT would also be = 2

I tried to use Set Analysis but I couldn't get what I need.

Do you know how could I do that?

Thank you!

1 Reply
vinieme12
Champion III
Champion III

Create numeric month fields if you don't have already and use the below expression

=count( {<NUM_MONTHStatus = {"<=$(=MIN(NUM_MONTHCal))"} , STATUS -={'Closed'} >}DISTINCT ID_TCKT)

LOAD ID_TCKT,

     STATUS,

     YEAR,

    MONTH_STATUS,

    NUM(Month(Date#(MONTH_STATUS, 'MMM')))  as NUM_MONTHStatus,

     CREATE_DATE,

     CREATE_TIME,

     MONTH_CALENDAR,

     NUM(Month(Date#(MONTH_CALENDAR, 'MMM')))  as NUM_MONTHCal

FROM

[https://community.qlik.com/thread/243734]

(html, codepage is 1252, embedded labels, table is @1);

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.