Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Static Count

See attached and below for sample data and app.

I would like to create a static count.

Criteria:

Dimension: StartDate_YYYYMM

Expression/Script:

  I would like to count all "active" from column StatusofMember AND when Statusofmember is closed with an enddate on or after the last day of the StartDate month. I broke it down below but I need help implmenting this into QV.

 

120161010/1/20163000011/1/3000Active
220161010/1/201620161111/15/2016Closed
1120161010/15/201620161111/30/2016Closed
320161010/15/20163000011/1/3000Active
420161010/1/20163000011/1/3000Active
1020161010/1/20163000011/1/3000Active
1220161010/1/201620161111/30/2016Closed
1320161111/1/20163000011/1/3000Active
1420161111/1/201620161212/1/2016Closed
1520161212/1/20163000011/1/3000Active

   

ExampleActiveClosed(Count last day of month or after)TotalActive IDClosed ID
2016104371,3,4,102,11,12
2016115381,3,4,10,1311,12,14
2016126061,3,4,10,13,15n/a

5 Replies
sunny_talwar

May be using IntervalMatch

Sample:

LOAD ID,

    Date(MonthStart(STARTDATE_YYYYMM), 'YYYYMM') as STARTDATE_YYYYMM,

    StartDate,

    Date(MonthStart(

      If(ENDDATE_YYYYMM = MakeDate(3000, 1), Today(),

      If(STATUSOFMEMBER = 'Closed' and Day(EndDate) = Day(MonthEnd(EndDate)), ENDDATE_YYYYMM, MonthStart(ENDDATE_YYYYMM)-1))), 'YYYYMM') as ENDDATE_YYYYMM_JOIN,

    ENDDATE_YYYYMM,   

    EndDate,

    STATUSOFMEMBER

FROM

[delete.xls]

(biff, embedded labels, table is Sample$);

Temp:

LOAD Date(AddMonths(Min, IterNo() - 1), 'YYYYMM') as MonthYear

While AddMonths(Min, IterNo() - 1) <= Max;

LOAD Min(STARTDATE_YYYYMM) as Min,

  Max(ENDDATE_YYYYMM_JOIN) as Max

Resident Sample;

Left Join (Sample)

IntervalMatch(MonthYear)

LOAD STARTDATE_YYYYMM,

  ENDDATE_YYYYMM_JOIN

Resident Sample;

Capture.PNG

vinieme12
Champion III
Champion III

haven't looked at your app, but if you want in Chart then try below

Active

count({<STATUSOFMEMBER={'Active'}>}ID)

Closed

sum( {<STATUSOFMEMBER={'Closed'} >} AGGR( if(EndDate >= MonthEnd(StartDate) ,1),ID))

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

Can I combine the two expressions into one?

johnw
Champion III
Champion III

Here's a different data model solution, with a separate table of the months that an ID could be considered active according to my understanding of your definition. Hopefully no bugs. Works at least on the sample data.

MonthsActive:
LOAD ID
,date(monthstart(StartDate,iterno()-1),'MMM YYYY') as ActiveMonth
RESIDENT Raw
WHILE daystart(monthend(StartDate,iterno()-1))<=rangemin(EndDate,monthend(today()))
;

Dimension  = ActiveMonth

Expression = count(distinct ID)

vinieme12
Champion III
Champion III

For the TOTAL you mean?

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