Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
Thanks for your help!
Hi Rusell,
With your data and this script, this will be your output:
Data:
LOAD Date,
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)
LOAD
MonthName,
COUNT(DISTINCT RowNum) as Occurrence,
[Guest Name]
RESIDENT Data
GROUP BY MonthName, [Guest Name];
FinalData:
LOAD
MonthName,
COUNT(DISTINCT RowNum) as Times,
COUNT(DISTINCT [Guest Name]) as Customers
RESIDENT Data
WHERE Occurrence > 1
GROUP BY MonthName;
Regards!!
Hi Russell,
Can you please share the sample data along with the expected output.
Regards,
Kaushik Solanki
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>
Hi Rusell,
With your data and this script, this will be your output:
Data:
LOAD Date,
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)
LOAD
MonthName,
COUNT(DISTINCT RowNum) as Occurrence,
[Guest Name]
RESIDENT Data
GROUP BY MonthName, [Guest Name];
FinalData:
LOAD
MonthName,
COUNT(DISTINCT RowNum) as Times,
COUNT(DISTINCT [Guest Name]) as Customers
RESIDENT Data
WHERE Occurrence > 1
GROUP BY MonthName;
Regards!!
Thank you so much, that's perfect!
You're wellcome
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
Hi, I use a count distinct: COUNT(DISTINCT [Guest Name])
Regards!!