Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I'm looking for a DAX pattern that will I dentify patrons who made a purchase in the 90 days prior to a specified date but did NOT make a purchase in the 90 days after that date. I've found some stuff in the forum that is similar, but I just can't seem to get it right.
Patrons could have made multiple purchases in the first period, but I'm only interested in identifying the unique customers. I'd want a measure that can provide KPIs (counts, $ spent, etc.), but I also need to FLAG the individual customers (I'm assuming with a calculated field) so that the non-returning customers can be contacted by CRM.
Suggestions? (Note: I just bought the most recent edition of DAX Patterns, so if there is something close in there - point me to it!)
Thanks. -Dom
Try Something like this
Customers Measure=
VAR comparableDate = SELECTEDVALUE(<date field>, <Alternative>)
VAR firstCustomerList = FILTER(<customerid field>,<date field> <= comparableDate && <date field> >=comparableDate - 90)
VAR secondCustomerList = FILTER(<customerid field>,<date field> > comparableDate && <date field> <=comparableDate + 90)
RETURN CALCULATE(COUNTROWS(firstCustomerList),NOT(secondCustomerList))
Hi @domtrump
you may try something like
Lost Customers =
VAR CurrentDate =
MAX ( 'Date'[Date] )
VAR PreviousCustomers =
CALCULATETABLE (
VALUES ( Sales[CustomerID] ),
'Date'[Date] < CurrentDate,
'Date'[Date] >= CurrentDate - 90,
ALL ( 'Date' )
)
VAR CurrentCustomers =
CALCULATETABLE (
VALUES ( Sales[CustomerID] ),
'Date'[Date] >= CurrentDate,
'Date'[Date] < CurrentDate + 90,
ALL ( 'Date' )
)
RETURN
COUNTROWS ( EXCEPT ( PreviousCustomers, CurrentCustomers ) )
Lost Sales =
VAR CurrentDate =
MAX ( 'Date'[Date] )
VAR PreviousCustomers =
CALCULATETABLE (
VALUES ( Sales[CustomerID] ),
'Date'[Date] < CurrentDate,
'Date'[Date] >= CurrentDate - 90,
ALL ( 'Date' )
)
VAR CurrentCustomers =
CALCULATETABLE (
VALUES ( Sales[CustomerID] ),
'Date'[Date] >= CurrentDate,
'Date'[Date] < CurrentDate + 90,
ALL ( 'Date' )
)
RETURN
CALCULATE ( [Sales Amount], ( EXCEPT ( PreviousCustomers, CurrentCustomers ) ) )
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
11 | |
10 | |
9 | |
8 |
User | Count |
---|---|
17 | |
12 | |
11 | |
11 | |
11 |