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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Aggr() Count help

Hi all,

I'm working with telecommunication/wireless telephone data, and I want to count the number of "Inactive" lines in a text box. What I've done so far is aggr() each phone line ("PhoneLineNumber" below) by the sum of their data + voice usage. Now what I want to do is count the numbers whenever that Aggr() expression evaluates to zero. How do I count those? Set analysis? If statement?

aggr(sum(UsageDataKBTotal) + sum(UsageTotalVoiceMOU), PhoneLineNumber)

Thanks!

1 Solution

Accepted Solutions
swuehl
MVP
MVP

=sum( aggr(if(sum(UsageDataKBTotal) + sum(UsageTotalVoiceMOU)=0,1), PhoneLineNumber) )

View solution in original post

7 Replies
swuehl
MVP
MVP

=sum( aggr(if(sum(UsageDataKBTotal) + sum(UsageTotalVoiceMOU)=0,1), PhoneLineNumber) )

MK_QSL
MVP
MVP

Didn't understand your question properly. Could you please elaborate little more?

Not applicable
Author

Thanks! Great use of sum rather than count().

-Paul

Not applicable
Author

Swuehl,

What if I only wanted to do the same as above, but only count the phone numbers of a certain length - such as where len(PhoneLineNumber) = 7? Is that possible?

Thanks

swuehl
MVP
MVP

Sure, maybe like

=count( if(len(PhoneLineNumber)=7,PhoneLineNumber))

or a distinct count if needed:

=count(DISTINCT if(len(PhoneLineNumber)=7,PhoneLineNumber))

?

Or prepare a field PhoneLineNumberLength in your script:

LOAD

     PhoneLineNumber,

     len(PhoneLineNumber) as PhoneLineNumberLength,

     ...

then

=count(DISTINCT {<PhoneLineNumberLength = {7}>} PhoneLineNumber)

Not applicable
Author

I mean inside the formula you provided above. Something like (although this doesn't work):

=sum( if(aggr(sum(UsageDataKBTotal) + sum(UsageTotalVoiceMOU), if(Len(PhoneLineNumber) = 12, PhoneLineNumber)) = 0, 1))

Not applicable
Author

I actually got it! Thanks for the help again:

=sum( if(Len(PhoneLineNumber) = 12 AND aggr(sum(UsageDataKBTotal) + sum(UsageTotalVoiceMOU), PhoneLineNumber) = 0, 1))