Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Count(if(aggr)) counts only the first value. Why?

I've got 2 tables:

t1:

Load CID,TID,date(Tdate,'DD.MM.YYYY')as TDATE Inline

[

  CID,TID,Tdate

  1,1,25.12.2014

  1,2,20.05.2014

  2,3,14.03.2015

  1,4,28.10.2015

];

t2:

Load CID,EID,date(Edate,'DD.MM.YYYY')as EDATE Inline

[

  CID,EID,Edate

  1,9,18.05.2014

  1,7,16.05.2014

  1,1,21.05.2014

  1,2,19.05.2014

  2,3,20.05.2014

  1,4,29.11.2015

  1,5,26.05.2014

  1,6,15.04.2014

  1,8,17.06.2014

];

and a straight table chart with a dimension CID and expression

Count(if(aggr(min(TDATE),CID)>EDATE, EID))

The count shows values = 1 for both CIDs, inspite that there are several (4) EIDs for CID=1 that suit the condition. I found out that the Count finds only the first suitable EDATE in the table, but for all others the condition is false. What's wrong?

3 Replies
Highlighted
Partner
Partner

Hi,

Try this

Count(If(Aggr(NODISTINCT Min(TDATE),CID)>Aggr(Only(EDATE),CID,EID),EID))

Highlighted
MVP
MVP

=SUM(IF(Date(Aggr(Only(EDATE),EID,CID)) <=Aggr(NODISTINCT Min(TDATE),CID),1,0))

Highlighted
Not applicable

Actually, in my case, adding nodistinct to aggr in initial expression solved the problem. So it became

Count(if(aggr(nodistinct min(TDATE),CID)>EDATE, EID))

But the real data model appears to be much more complicated and the trick doesn't work well. So I'll try to adapt it to my solution. If fail, I'll come back for more assistance. Anyway, thank you, guys!