Forum Discussion
Help understanding this DAX
Yamabushi Please find the summary
MAX(DimDate[FullDateAlternateKey]): This part finds the maximum (latest) date in the DimDate table.
MAX(DimDate[FullDateAlternateKey]) - 2: Subtracting 2 days from the latest date gives you a date that is 2 days ago.
DimDate[FullDateAlternateKey] > MAX(DimDate[FullDateAlternateKey]) - 2: This condition filters dates that are greater than 2 days ago.
DimDate[FullDateAlternateKey] <= MAX(DimDate[FullDateAlternateKey]): This condition filters dates up to the latest date.
AND(...): The AND function combines the two conditions, ensuring that the date is within the last 2 days.
CALCULATE([Total Sales], ...): Finally, the CALCULATE function applies these date filters to the [Total Sales] measure, giving you the total sales for the last 2 days
And accept as solutin if it helps
Hi,
thank you, @bhanu, but that was not what I was asking. I understand what each function individually does. My question specifically relates to evaluation context:
- Why is DimDate[FullDateAlternateKey] in MAX evaluated in the original evaluation context?
- Why is DimDate[FullDateAlternateKey] on the left side of the comparison operator evaluated in the evaluation context coming from CALCULATE?
- In formulas like this, how do we know when something is evaluated in a modified evaluation context, and when something is being evaluated in the original evaluation context?
Thanks!