Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi all,
I am trying to create a measure that shows the number of days between:
A) The MAX transaction date that each customer buys a specific product. This product is selected by a filter. And
B) Each subsequent transaction made by that customer, for every single product (not just the filtered item).
In the below example, Product A has been selected using the filter.
Is this possible using DAX?
Solved! Go to Solution.
Hi @chuckle,
Please check following steps and see if the result achieve your expectation:
1. Create calculated table as slicer:
Table 2 = DISTINCT('Table'[product])
2. Create measure:
Measure =
var sv = SELECTEDVALUE('Table 2'[product])
var a = CALCULATE(MAX('Table'[date]),FILTER(ALL('Table'),'Table'[customer] = MAX('Table'[customer])&&'Table'[product] = sv))
var b = CALCULATE(MAX('Table'[date]),FILTER(ALL('Table'),'Table'[customer] = MAX('Table'[customer])&&'Table'[product] = MAX('Table'[product])))
return
IF(NOT(ISFILTERED('Table 2'[product])),"",IF(MAX('Table'[product]) = sv,"",IF(MAX('Table'[date])=b,DATEDIFF(a,MAX('Table'[date]),DAY),"")))
3. Result would be shown as below:
BTW, Pbix as attached, hopefully works for you.
Best Regards,
Jay
Community Support Team _ Jay Wang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @chuckle,
Please check following steps and see if the result achieve your expectation:
1. Create calculated table as slicer:
Table 2 = DISTINCT('Table'[product])
2. Create measure:
Measure =
var sv = SELECTEDVALUE('Table 2'[product])
var a = CALCULATE(MAX('Table'[date]),FILTER(ALL('Table'),'Table'[customer] = MAX('Table'[customer])&&'Table'[product] = sv))
var b = CALCULATE(MAX('Table'[date]),FILTER(ALL('Table'),'Table'[customer] = MAX('Table'[customer])&&'Table'[product] = MAX('Table'[product])))
return
IF(NOT(ISFILTERED('Table 2'[product])),"",IF(MAX('Table'[product]) = sv,"",IF(MAX('Table'[date])=b,DATEDIFF(a,MAX('Table'[date]),DAY),"")))
3. Result would be shown as below:
BTW, Pbix as attached, hopefully works for you.
Best Regards,
Jay
Community Support Team _ Jay Wang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
User | Count |
---|---|
144 | |
72 | |
62 | |
52 | |
48 |
User | Count |
---|---|
208 | |
89 | |
61 | |
59 | |
57 |