I Know for example for Filtering Measures We can’t Use CALCULATE, But for These Two example I don’t Know Why we should use FILTER Function Inside CALCULATE.

thanks @Melissa for your response and thanks @sam.mckay for these great videos. I Saw all of these video but I Couldn’t find any reason to use FILTER function in CALCULATE Argument.

So here’s what calculate does: it evaluates an expression in a context modified by filters.
For the second argument (filter(s)) a boolean (True/False) expression or a table expression that defines a filter can be passed.

When a filter argument has the form of a predicate with a single column reference, the expression is internally converted into a FILTER( ALL (table[column] ), Condition - so this:

However this doesn’t mean the second argument has to be the FILTER function, it can be any table expression returning a list of values for one or more columns or for an entire expanded table.

To augment the excellent information that @Melissa has provided, I’ve always found this video helpful in addressing this topic with a number of very common and clear-cut examples.

I think you are getting there… if I stick with your example, this:

myMeasure =
VAR X = MAX( Dates[Date] )
RETURN
CALCULATE([Total Sales],
Dates[Date]<= X
)

will internally be translated into

myMeasure (full) =
VAR X = MAX( Dates[Date] )
RETURN
CALCULATE([Total Sales],
FILTER( ALL( Dates[Date] ),
Dates[Date]<= X
)
)

So although you don’t have to write FILTER( ALL( Dates[Date] ) as shown in the first measure that is still what the DAX engine is doing behind the scenes…

Therefor I would recommend to always write it out fully (like the second measure) because as you get more comfortable with writing DAX and the logic get’s more complex it is vital that you understand exactly how the context of an expression has been modified inside CALCULATE.