Hi Mark,

First quick thingâ€¦really recommend working on the way your formulas are set out. It may seem like a small thing but will really pay dividends in the long term. DAX can get quite complicated and structuring things well will speed up your development, Iâ€™m 100% confident in this.

See below for more ideas

Whenever I look at problems like this one I always try to work out the simplest way to solve it first and weigh up is it optimal enough versus any alternative.

Something there may be more theoretically optimal ways to solve it but I will always go to the simplest if I feel it is good enough.

I understand better now the main issue here so this is how I would solve it.

First I would try to get a calculated column the shows the days difference between all the inspections.

(Letâ€™s start here and then see if itâ€™s easy enough to move it into a measure)

```
Last Search Date =
VAR CurrentSearchDate = 'Cases Data'[Case Search Date]
VAR CurrentProduct = 'Cases Data'[Product]
RETURN
CALCULATE( MAX( 'Cases Data'[Case Search Date] ),
FILTER( 'Cases Data', 'Cases Data'[Case Search Date] < CurrentSearchDate ),
FILTER( 'Cases Data', 'Cases Data'[Product] = CurrentProduct ) )
```

You see with this formula I am grabbing the last date for every product in this case.

Then you can get to here very easily

```
Search Date Difference =
IF( ISBLANK( 'Cases Data'[Last Search Date] ),
BLANK(),
'Cases Data'[Case Search Date] - 'Cases Data'[Last Search Date] )
```

Then once you have this column all you would need it something as simple as this

```
Average Difference =
AVERAGEX( 'Cases Data',
'Cases Data'[Search Date Difference] )
```

This should do it for you I believe.

See how you go with these ideas

Chrs