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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Power
Contributor
Contributor

if count

Hello,

i am relatively new to the tool so any help will be much appreciated. I wanna assign a string when a customer code appears 1, between 1 and 5 or a number >5.

The classic excel logic would look like this:

if( [state] = 'payed',
     if( count([customer]) = 1, 'One timer',
         if( count([customer]) > 1 and count([customer]) < 5, 'Medium user', 'Heavy user')),'')

I know that putting if and a count in this order doen not work here and i could not find a suitable solution between the post i have seen. Can someone give me some suggestion on how to obtain the result?

Labels (1)
2 Replies
MayilVahanan
MVP
MVP

HI @Power 

Try like below

Load yourprimarykeyfield,

if( [state] = 'payed',
     if( count([customer]) = 1, 'One timer',
         if( count([customer]) > 1 and count([customer]) < 5, 'Medium user', 'Heavy user')),'') as UsrType

Resident ursourcetablename

group by yourprimarykeyfield;

Then in front end, u can use UsrType as ur dimension.

---------------

Suppose, u want to achieve only in front end. try like below

Aggr(if( [state] = 'payed',
     if( count([customer]) = 1, 'One timer',
         if( count([customer]) > 1 and count([customer]) < 5, 'Medium user', 'Heavy user')),''), UrPrimaryFieldName)

For performance wise, try in backend.

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Power
Contributor
Contributor
Author

Hi @MayilVahanan,

Thanks for your answer. I tried it, can you specify where should i put it in the editor in order to make it work properly. I couldn't. I am tryin to learn and solve things in different ways. In this particular case i would like not to break the autogenerated code in the editor, so can i put the new variables etc. in a manually generated section and then load the whole script expecting it to work?

Thanks in advance for your time, i know some of my points could sound obvious.

 

 

Community Browser