Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Coun Users and SUM (Combining IF and SET ANALYSIS)

I Have the following Fields

USER_ID,MMYY,  AMOUNT , TRAVEL, LODGING, FOOD_PUB, FOOD_RESTAURANT, FOOD_FAST, MOVIES, HEALTHCARE

I want to find COUNT users who TRAVEL , Stayed in LODGING and Spent on FOOD . Also SUM the  AMOUNT SPENT all these expenses.

What is the best way to count as well as SUM of All those Fields.

I have started as follows for count

=COUNT (DISTINCT (if TRAVEL > 0, if LODGING > 0, COUNT (DISTINCT { <  FOOD_PUB  = '>0' > + <  FOOD_RESTAURANT= '>0' >  +  <  FOOD_FAST= '>0' > } USER_ID)))

But I am confused because can't use COUNT statement twice..

Thank you in advance for your help

3 Replies
Not applicable
Author

Is this expression for count.

= COUNT (DISTINCT { <TRAVEL = {'>0'}> * <LODGING = {'>0'}> *      (  <FOOD_PUB= {'>0'}> + <FOOD_RESTAURANT= {'>0'}>   + <FOOD_FAST= {'>0'}> ) } USER_ID )

Is this correct? Please note I have added explicit ()

Not applicable
Author

Mohit,

Thanks for the help. But it is not working.

Here are my data for testing..(See attached excel file)

DataScreen.PNG

If I use the following Expression, I get 21

=COUNT(DISTINCT {<TRAVEL = {'>0'}> * <LODGING = {'>0'}> * (<FOOD_PUB = {'>0'}> + <FOOD_REST = {'>0'}>  + <FOOD_FAST = {'>0'}> )} USER_ID)

If I use the expression as per your suggestion I get 24

=COUNT(DISTINCT {<TRAVEL = {'>0'}> * <LODGING = {'>0'}> * <FOOD_PUB = {'>0'}> + <FOOD_REST = {'>0'}>  + <FOOD_FAST = {'>0'}> } USER_ID)

I am not sure we can use parentheses with in Set Expression.

I have also attached qlikview files..

How to add SUM?

Thanks

Not applicable
Author

Mohit

It does not work..