Forum Discussion
Date Issue
- 1 month ago
The error occurs because you’re creating a measure, but [Created Date] and [Resolved Date] contain multiple rows. DAX needs an aggregation or a single selected value.
maybe you can try this
Resolution Days =
VAR CreatedDate =
SELECTEDVALUE('June 1 to Aug 19'[Created Date])
VAR ResolvedDate =
SELECTEDVALUE('June 1 to Aug 19'[Resolved Date])
RETURN
IF(
NOT ISBLANK(CreatedDate) &&
NOT ISBLANK(ResolvedDate),
DATEDIFF(CreatedDate, ResolvedDate, DAY)
)
if this does not work, pls provide your sample data and expected output.
Hi njsimmons82
If you want Resolution Days per ticket as row by row then create Calculated Column instead Measure
Resolution Days =
DATEDIFF(
'June 1 to Aug 19'[Created Date],
'June 1 to Aug 19'[Resolved Date],
DAY)
In calculated column DAX evaluates it row by row, so there is an implicit row context and each row's own Created or Resolved Date is used with no error
If you want a measure then you need to use column in an aggregation as measure has to view many rows into one number
Avg Resolution Days =
AVERAGEX(
'June 1 to Aug 19',
DATEDIFF(
'June 1 to Aug 19'[Created Date],
'June 1 to Aug 19'[Resolved Date],
DAY))
AVERAGEX or SUMX iterates row by row internally computing DATEDIFF for each row and aggregates the results