Forum Discussion
Average days between two dates
- 5 years ago
Hi Anonymous ,
According to your request, I did the following test: dateKey_FK is a separate date list, and there is no relationship between the two tables. Reference is as follows:
avg_day = VAR a = MIN ( dateKey_FK[Date] ) VAR b = MAX ( dateKey_FK[Date] ) VAR c = CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( ALL ( 'Table' ), 'Table'[Orderdate] >= a && 'Table'[RegisterOrderdate] <= b ) ) VAR d = CALCULATE ( SUM ( 'Table'[day_diff] ), FILTER ( ALL ( 'Table' ), 'Table'[Orderdate] >= a && 'Table'[RegisterOrderdate] <= b ) ) RETURN d / cBelow is the sample pbix file.
If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.
Best Regards,
Henry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous , This filter is on which date- orderdate or register_orderdate ?
you can get Avg as
averageX(Table, Datediff(orderdate, register_orderdate, day))
It's based on datekey_FK.
- amitchandak5 years agoSuper User
Anonymous , sorry I did not get it yet. But how datekey_FK is related to the data you have shown or how you want it to be related?