The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi all,
Need your help. I'm trying to flag customers that made multiple purchases in the same day. The purchase ID must be within 3 numbers of each other. So the same customer on the same day makes purchase ID 100, 103, and 104 should all be flagged as consecutive. Below is a sample table and the consecitive column is what I'm trying to calculate.
Customer | Date | Purchase ID | Consecutive |
A | 4/30/2025 | 1125 | No |
B | 5/20/2025 | 1244 | No |
C | 3/5/2025 | 1003 | Yes |
C | 3/5/2025 | 1004 | Yes |
C | 3/5/2025 | 1006 | Yes |
D | 6/10/2025 | 1356 | No |
D | 6/11/2025 | 1357 | No |
E | 6/12/2025 | 1391 | No |
E | 6/12/2025 | 1395 | No |
Solved! Go to Solution.
Hi @buttercream
Consider building a new Column in your table with below:
Hi,
This calculated column formula works
=if(CALCULATE(COUNTROWS(Data),FILTER(Data,Data[Customer]=EARLIER(Data[Customer])))=1,"No",if(or(Data[Purchase ID]-CALCULATE(MAX(Data[Purchase ID]),FILTER(Data,Data[Customer]=EARLIER(Data[Customer])&&Data[Date]=EARLIER(Data[Date])&&Data[Purchase ID]<EARLIER(Data[Purchase ID])))<=3,and(CALCULATE(min(Data[Purchase ID]),FILTER(Data,Data[Customer]=EARLIER(Data[Customer])&&Data[Date]=EARLIER(Data[Date])&&Data[Purchase ID]>EARLIER(Data[Purchase ID])))-Data[Purchase ID]<=3,CALCULATE(min(Data[Purchase ID]),FILTER(Data,Data[Customer]=EARLIER(Data[Customer])&&Data[Date]=EARLIER(Data[Date])&&Data[Purchase ID]>EARLIER(Data[Purchase ID])))-Data[Purchase ID]>0)),"Yes","No"))
Hope this helps.
Hi @buttercream
Consider building a new Column in your table with below:
Perfect. Thank you !!!