7 Replies Latest reply: Aug 31, 2016 5:26 AM by Manuel Capella

# Number of Occurances

Hi All, I have a dataset of the customers to an F&B outlet at a hotel.

I would like to show the number of repeat guests to the restaurant each month so need to count the occurrences of each guest name and then show only those greater than 1 by month.  Can anyone advise on the script for this?

In the bar chart I would just like to show each month the number of repeat guests which I will show as a percentage of total guests for the month.

• ###### Re: Number of Occurances

Hi Russell,

Can you please share the sample data along with the expected output.

Regards,

Kaushik Solanki

• ###### Re: Number of Occurances

Hi Kaushik, thank you for your reply.  Some data is attached here.

I would like to eliminate all guests with an occurrence of only 1 and to

sum (or count) the remaining.

e.g. if Paul has 3 occurrences, Russell and 2 Occurrences and Steve has 1

occurrence.

By 1st eliminating Steve who has only 1 occurrence the sum would be 5 and

the count would be 2.

Thanks for your help, really appreciated.

Russell

On Tue, Aug 30, 2016 at 4:59 PM, Kaushik Solanki <qcwebmaster@qlikview.com>

• ###### Re: Number of Occurances

Hi Rusell,

```Data:
MonthName(Date) as MonthName,
RowNo()         as RowNum,
Time,
BillNo,
Total,
[Guest Name]
FROM
[Data for Occurance Question.xlsx]
(ooxml, embedded labels, table is Sheet1);

Occurences:
LEFT JOIN (Data)
MonthName,
COUNT(DISTINCT RowNum) as Occurrence,
[Guest Name]
RESIDENT Data
GROUP BY MonthName, [Guest Name];

FinalData:
MonthName,
COUNT(DISTINCT RowNum) as Times,
COUNT(DISTINCT [Guest Name]) as Customers
RESIDENT Data
WHERE Occurrence > 1
GROUP BY MonthName;
```

Regards!!

• ###### Re: Number of Occurances

Thank you so much, that's perfect!

• ###### Re: Number of Occurances

You're wellcome

• ###### Re: Number of Occurances

Could you please let me know how you could get the customers as 10 , i have got everything else right but customers i am not able to get the right number,can you tell me what expression you used in the chart

• ###### Re: Number of Occurances

Hi, I use a count distinct: COUNT(DISTINCT [Guest Name])

Regards!!