Forum Discussion
jason435
Helper II
8 years agoTransactions by New or Returning Customers
I am trying to measure hotel guest stays by new or returning customers. I'm counting stays, not customers. All the other solutions I have found count new vs returning customers. My table is like ...
jason435
Helper II
8 years agoThank you. I had a feeling there was probably a simpler way.
This formula from you works for giving new or repeat for each stayID:
Stay ID of the first visit = CALCULATE(MIN(Transactions[StayID]),
ALLEXCEPT(Transactions,Transactions[CustomerKey]))
Stay Type = if(HASONEVALUE(Transactions[Date]), if( COUNTROWS( FILTER( SUMMARIZE( Transactions,Transactions[CustomerKey], "EFGH",MAX(Transactions[StayID]), "IJKL",[Stay ID of the first visit]), [EFGH]=[IJKL])) >0,"New","Repeat"),BLANK())
I understand how it works. Just one question, why do you use if(hasonevalue(...)..)? I don't understand the need.
As my ultimate goal was to have a count of stayID with new or old customers, I played with your formula some more and found this seems to work:
Stay Count New Customers=
COUNTROWS(
FILTER(
SUMMARIZE(
Transactions,Transactions[CustomerKey],
"EFGH",MIN(Transactions[StayID]),
"IJKL",[Stay ID of the first visit]),
[EFGH]=[IJKL]))I had to change from MAX(Transactions[StayID]) to MIN(Transactions[StayID]) as that would cause a wrong answer if the same Customer came back during the period.
Thanks again.
Ashish_Mathur
Super User
8 years agoHi,
You are welcome. I used the HASONEVALUE() to conceal the figure in the Grand Total row.
If my reply helped, please mark it as Answer.