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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Count/IF Expression issue

Hi All,

I am trying to find the count of those distinct UserID's who have login count more than one.

The below expression is nt fetching the correct result.

Any help on this please

=Count({< UserID= {"=count({<PG_NM = {Login}>} UserID)>1 "} >} distinct  UserID)

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Ok, I missed that you are using the field modifier within another field modifier search expression.

Right, this could makes things more complicated.

Easiest solution would be to strip the double quotes when reading from your DB:

LOAD

     purgechar(PG_NM, '"') as PG_NM,

....

FROM ....;

View solution in original post

10 Replies
tresesco
MVP
MVP

try putting single quotes around string 'Login' like:

=Count({< UserID= {"=count({<PG_NM = {'Login'}>} UserID)>1 "} >} distinct  UserID)

swuehl
MVP
MVP

Well, that's hard to answer without knowing your data model and data.

You'll need to add more information about the data itself, the context you are using this expression in and the expected outcome.

If

=count({<PG_NM = {Login}>} UserID)


used in a straight table with dimension UserID returns correct results for Login count, your expression should return the correct number e.g. in a text box.

Not applicable
Author

Actually Login  has double quotes in it "Login"{in DB}

When i am trying that its throwing an error

=Count({< UserID= {"=count({<PG_NM = {' " Login" '}>} UserID)>1 "} >} distinct  UserID)

Not applicable
Author

you could write an sql query..

select count(*) as num_of_logins,userid,login from <table> group by userid,login having count(*)>1;

swuehl
MVP
MVP

What kind of error do you get using the single quotes in your field modifier value list? Seems that you are using additional spaces, but something like

=Count({< UserID= {"=count({<PG_NM = {'"Login"'}>} UserID)>1 "} >} distinct  UserID)


works for me.

Not applicable
Author

UserID (Person_addm2_key )

Error.jpg

swuehl
MVP
MVP

Ok, I missed that you are using the field modifier within another field modifier search expression.

Right, this could makes things more complicated.

Easiest solution would be to strip the double quotes when reading from your DB:

LOAD

     purgechar(PG_NM, '"') as PG_NM,

....

FROM ....;

somenathroy
Creator III
Creator III

U may try :

if(Aggr(Count({<PG_NM={'"Login"'}>}PG_NM),UserID) >1,Aggr(Count({<PG_NM={'"Login"'}>}PG_NM),UserID))

Regards,

Som

Not applicable
Author

Hey Thanks swuehl!!

The expression worked for me .

I Used purgechar(PG_NM, '"') as PG_NM and

then gave the expression as

=Count({< UserID= {"=count({<PG_NM = {'Login'}>} UserID)>1 "} >} distinct  UserID)