Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello!
I'm looking for a formula to calculate how many weeks it has been since a store has last ordered product.
Below is a simple pivot that I would like to turn into a single column with the above formula. For example, it has been "5" weeks since the below store has last ordered product.
Thank you so much in advance for your help!!
Solved! Go to Solution.
Hi @AndrewUrban
Thanks for reaching out to us.
>>For example, it has been "5" weeks since the below store has last ordered product.
You can try this measure.
Measure =
var _lastDate=MAXX(FILTER('Table','Table'[qty]>0),'Table'[date])
var _maxDate=MAXX('Table',[date])
var _weeks= DATEDIFF(_lastDate,_maxDate,WEEK)
return "Weeks since Last Ordered: "&_weeks
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
Hi @AndrewUrban
Thanks for reaching out to us.
>>For example, it has been "5" weeks since the below store has last ordered product.
You can try this measure.
Measure =
var _lastDate=MAXX(FILTER('Table','Table'[qty]>0),'Table'[date])
var _maxDate=MAXX('Table',[date])
var _weeks= DATEDIFF(_lastDate,_maxDate,WEEK)
return "Weeks since Last Ordered: "&_weeks
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
You're a genius & a scholar! Thank you!
If you are just looking to convert that matrix then you don't have to do much.
Regards,
Ritesh
Thanks for the quick response, that doesn't seem to work here, see below. The returned output should be 2 & it's 0 across all stores. Any thoughts? Thanks again!
Oh yes, I used Column here.(Try using it)
Let me know if you want to use measure
I used the column with the formula you listed and it doesn't look like that worked either, i'm thinking there's an extra layer to the formula needed to avoid counting all of the "0" weeks & just counting the most recent. Thanks!
You can try
Num weeks since last order =
var lastOrder = MAX( 'Table'[Order date])
return DATEDIFF( lastOrder, TODAY(), WEEK)
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
49 | |
25 | |
20 | |
15 | |
12 |
User | Count |
---|---|
57 | |
49 | |
44 | |
19 | |
18 |