Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi all,
I want to create a measure that calculates the number of days between a customer buys a product and returns it (if that happens).
Our sales are stored in rows in a table like the one below:
Every bought product is stored in individual rows and has an unique purchase ID. Can anyone help to count the number of days between the pruchase date and the return date?
Best,
NicoM96
Solved! Go to Solution.
Hi @Anonymous ,
According to your description, here's my solution.
Create a measure.
Measure =
IF (
MAX ( 'Table'[Purchase/return] ) = "return",
DATEDIFF (
MAXX (
FILTER (
ALL ( 'Table' ),
'Table'[Product] = MAX ( 'Table'[Product] )
&& 'Table'[Purchase ID] = MAX ( 'Table'[Purchase ID] )
&& 'Table'[Date] <= MAX ( 'Table'[Date] )
&& 'Table'[Purchase/return] = "Purchase"
),
'Table'[Date]
),
MAX ( 'Table'[Date] ),
DAY
),
BLANK ()
)
Get the expected result.
I attach my sample below for reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
According to your description, here's my solution.
Create a measure.
Measure =
IF (
MAX ( 'Table'[Purchase/return] ) = "return",
DATEDIFF (
MAXX (
FILTER (
ALL ( 'Table' ),
'Table'[Product] = MAX ( 'Table'[Product] )
&& 'Table'[Purchase ID] = MAX ( 'Table'[Purchase ID] )
&& 'Table'[Date] <= MAX ( 'Table'[Date] )
&& 'Table'[Purchase/return] = "Purchase"
),
'Table'[Date]
),
MAX ( 'Table'[Date] ),
DAY
),
BLANK ()
)
Get the expected result.
I attach my sample below for reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi:
If you want to see positive value for answer it would be:
Hi Nico:
I was calling your table "Purchases.
I added Calc col
I hope you can mark as solved. Thanks..
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 9 | |
| 9 | |
| 8 | |
| 6 | |
| 5 |
| User | Count |
|---|---|
| 23 | |
| 18 | |
| 16 | |
| 15 | |
| 14 |