The solution in a single measure is the following one:

```AverageDeltaSingleMeasure :=
AVERAGEX (
Sales,
CALCULATE (
MAXX ( Sales, RELATED ( 'Date'[Date] ) ),
USERELATIONSHIP ( 'Date'[DateKey], Sales[DeliveryDateKey] ),
ALL ( 'Date' )
) - RELATED ( 'Date'[Date] )
)
```

In order to understand how to create such a calculation, it is better to see a step-by-step approach, using calculated columns.

The first calculated column is straightforward:

```Sales[OrderDate] = RELATED ( 'Date'[Date] )
```

The second one requires a bit more attention, you might have tried this:

```Sales[DeliveryDate] =
CALCULATE (
RELATED ( 'Date'[Date] ),
USERELATIONSHIP ( 'Date'[DateKey], Sales[DeliveryDateKey] )
)
```

However, RELATED requires a row context which CALCULATE removes right before computing its formula. Thus, RELATED will not work inside CALCULATE. You can leverage RELATED anyway, by creating a technical row context iterating on Sales, which contains the row on which you are iterating:

```Sales[DeliveryDate] =
CALCULATE (
MAXX ( Sales, RELATED ( 'Date'[Date] ) ),
USERELATIONSHIP ( 'Date'[DateKey], Sales[DeliveryDateKey] )
)
```

Unfortunately, this formula always returns a blank result. The reason is that context transition started by CALCULATE filters Date too, because the expanded version of Sales contains all the columns of Date. Inside CALCULATE, the only date visible is the one related to the order date. If you want to make the inner RELATED work, you need to cancel the effect of context transition on Date by using ALL ( Date ). Thus, the final solution is:

```Sales[DeliveryDate] =
CALCULATE (
MAXX ( Sales, RELATED ( 'Date'[Date] ) ),
USERELATIONSHIP ( 'Date'[DateKey], Sales[DeliveryDateKey] ),
ALL ( 'Date' )
)
```

Once this column is in place, the remaining part is a very simple AVERAGEX:

```AverageDelta := AVERAGEX ( Sales, Sales[DeliveryDate] - Sales[OrderDate] )
```