Forum Discussion
dw700d
Post Patron
5 years agoCalculating date difference
I’m not sure if this is possible in power bi. But if it is I could use some guidance. I am trying to calculate the difference between two dates. The first date is a purchase date. The second date is ...
- 5 years ago
Hi dw700d,
Try measure as:
Measure = var _date1= CALCULATE( MAX(Table1[purchase date]), FILTER( Table1, Table1[Order number]=MAX(Table2[Order number]) ) ) var _date2= CALCULATE( MAX(Table2[Payment Date ]), FILTER( ALL(Table2), Table2[Order number]=MAX(Table2[Order number]))) return DATEDIFF(_date1,_date2,DAY)Here is the output:
Here is the demo, please try it: Calculating date difference
Best Regards,
Link
parry2k
Super User
5 years agodw700d add the following column, assuming these two tables are linked on Order Number
Days =
VAR __pmtTable = CALCULATE ( MAX ( 'PaymentTable'[Payment Date] ) )
RETURN
DATEDIFF ( PurchaseTable[purchase date], __pmtTable, DAY )
Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡