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.
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 / c
Below 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.