Don't miss your chance to take exam DP-600 or DP-700 on us!
Request nowLearn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
Hello everyone ,
I want to do two things in power bi : first , calculate the customer retention by quarters , years and centers( Customers who returned from the previous quarter to the same center) ex [jan 2023, feb 2023, mar 2023 will look from Oct 2022 , Nov 2022, Dec 2022] I do not want to count the same customer more than one in the same quarter.
Second, calculate the new customers in each quarter .
I have only one table (customers) with date and guest code columns
I did a small sample here
How I can do like this in power bi ?
I will be happy if you can help me.
As attachment the pbix file.
Try this measure:
I tried to remove the center ( Table1[Center] = Center)
and it is work
but i need it by centers
@manar_alamri
try this measure:
Customer Retention =
VAR CurrentPeriodStart = STARTOFQUARTER(Table1[date])
VAR CurrentPeriodEnd = ENDOFQUARTER(Table1[date])
VAR PreviousPeriodStart = PREVIOUSQUARTER(STARTOFQUARTER(Table1[date]))
VAR PreviousPeriodEnd = PREVIOUSQUARTER(ENDOFQUARTER(Table1[date]))
RETURN
CALCULATE(
DISTINCTCOUNT(Table1[guest code]),
FILTER(
Table1,
Table1[date] >= CurrentPeriodStart && Table1[date] <= CurrentPeriodEnd &&
Table1[guest code] IN
CALCULATETABLE(
VALUES(Table1[guest code]),
Table1[date] >= PreviousPeriodStart && Table1[date] <= PreviousPeriodEnd,
Table1[Center] = EARLIER(Table1[Center])
)
)
)
You can adjust the period if you need monthly retention instead of quarterly by modifying the STARTOFQUARTER and ENDOFQUARTER functions to STARTOFMONTH and ENDOFMONTH respectively.
Regards
Hi @manar_alamri
try this measure:
Thank you @lucadelicio the new client measure is work !
can you help me on Customers retention also ?
@manar_alamri , Try using measures for all 3 and create a separate date table for this
PreviousQuarterCustomers =
CALCULATE(
DISTINCTCOUNT(customers[guest_code]),
DATEADD(customers[date], -1, QUARTER)
)
CurrentQuarterCustomers =
DISTINCTCOUNT(customers[guest_code])
RetainedCustomers =
CALCULATE(
DISTINCTCOUNT(customers[guest_code]),
FILTER(
customers,
customers[guest_code] IN
CALCULATETABLE(
VALUES(customers[guest_code]),
DATEADD(customers[date], -1, QUARTER)
)
)
)
And one for new customers
NewCustomers =
CALCULATE(
DISTINCTCOUNT(customers[guest_code]),
EXCEPT(
VALUES(customers[guest_code]),
CALCULATETABLE(
VALUES(customers[guest_code]),
DATEADD(customers[date], -1, QUARTER)
)
)
)
Proud to be a Super User! |
|
I tried to do your solution but the value is showing blank on RetainedCustomers
and on NewCustomers the value shows the distinct guest code on the quarter ( it's not give me the new customers in the quarter)
| User | Count |
|---|---|
| 50 | |
| 40 | |
| 32 | |
| 14 | |
| 13 |
| User | Count |
|---|---|
| 87 | |
| 73 | |
| 37 | |
| 28 | |
| 26 |