I have the following measure

LastInventoryCountInTable:=SUMX(

dimItems

;CALCULATE(

SUM(factInventory[Quantity])

;FILTER(

ALL(dimCalendar)

;dimCalendar[Date] =

CALCULATE(

MAX(factInventory[Date])

;FILTER(

ALL(dimCalendar)

;dimCalendar[Date] <= MAX(dimCalendar[Date])

)

)

)

)

)

Why is that not the same as the following measure that is broken down into pieces:

LastInventoryCountInTable:=SUMX(

dimItems

;CALCULATE(

SUM(factInventory[Quantity])

;FILTER(

ALL(dimCalendar)

;dimCalendar[Date] = [LastInventoryDate]

)

)

)

LastInventoryDate:=CALCULATE(

MAX(factInventory[Date])

;FILTER(

ALL(dimCalendar)

;dimCalendar[Date] <= MAX(dimCalendar[Date])

)

)

I like the idea of breaking down problems into several measures. But I don't understand why the measures above aren't identical.