Forum Discussion
Mario_Sam
9 months agoNew Member
DAX Mesure
I have a customer retention report in Power BI and I’m trying to calculate a measure that represents Active Repeat Customers The business logic is a bit complicated and I could not find a working sol...
- 9 months ago
Hi Mario_Sam,
You can create the following DAX measure to correctly handle the rolling window and the current active condition:
Active Repeat Customers (90D) = VAR MaxSelectedDate = MAX ( 'Date'[Date] ) VAR Recent90DaySales = CALCULATETABLE ( Sales, DATESINPERIOD ( 'Date'[Date], MaxSelectedDate, -90, DAY ) ) VAR RepeatCustomers = FILTER ( SUMMARIZE ( Recent90DaySales, Sales[CustomerID], "OrderCount", COUNTROWS ( Recent90DaySales ) ), [OrderCount] >= 2 ) VAR ActiveCustomers = CALCULATETABLE ( VALUES ( Sales[CustomerID] ), KEEPFILTERS ( 'Date'[Date] ) ) RETURN COUNTROWS ( INTERSECT ( RepeatCustomers, ActiveCustomers ) )if this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly.
Ahmed-Elfeel
Super User
9 months agoHi Mario_Sam,
You can create the following DAX measure to correctly handle the rolling window and the current active condition:
Active Repeat Customers (90D) =
VAR MaxSelectedDate =
MAX ( 'Date'[Date] )
VAR Recent90DaySales =
CALCULATETABLE (
Sales,
DATESINPERIOD (
'Date'[Date],
MaxSelectedDate,
-90,
DAY
)
)
VAR RepeatCustomers =
FILTER (
SUMMARIZE (
Recent90DaySales,
Sales[CustomerID],
"OrderCount", COUNTROWS ( Recent90DaySales )
),
[OrderCount] >= 2
)
VAR ActiveCustomers =
CALCULATETABLE (
VALUES ( Sales[CustomerID] ),
KEEPFILTERS ( 'Date'[Date] )
)
RETURN
COUNTROWS (
INTERSECT ( RepeatCustomers, ActiveCustomers )
)
if this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly.
Mario_Sam
9 months agoNew Member
Hi Ahmed-Elfeel
Thanks for the answer it worked ,Thank you so much