Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Yamabushi
Helper I
Helper I

Help understanding this DAX

Hi,

 

I wish to understand this measure, especially the part in AND():

30 Day Total Sales =
CALCULATE(
    [Total Sales],
    AND(
        DimDate[FullDateAlternateKey] > MAX(DimDate[FullDateAlternateKey]) - 2,
        DimDate[FullDateAlternateKey] <= MAX(DimDate[FullDateAlternateKey])
    )
)
 
Yamabushi_0-1704813375634.png

 

 
I know that there is an implicit FILTER(ALL()) going on that removes the filter from FullDateAlternateKey, so how does DAX know to use the date where the filter context is removed on the left side of the condition, and the original filter context on the right side of the condition (in MAX()).
 
Thank you!
2 REPLIES 2
bhanu_gautam
Super User
Super User

@Yamabushi  Please find the summary

  1. MAX(DimDate[FullDateAlternateKey]): This part finds the maximum (latest) date in the DimDate table.

  2. MAX(DimDate[FullDateAlternateKey]) - 2: Subtracting 2 days from the latest date gives you a date that is 2 days ago.

  3. DimDate[FullDateAlternateKey] > MAX(DimDate[FullDateAlternateKey]) - 2: This condition filters dates that are greater than 2 days ago.

  4. DimDate[FullDateAlternateKey] <= MAX(DimDate[FullDateAlternateKey]): This condition filters dates up to the latest date.

  5. AND(...): The AND function combines the two conditions, ensuring that the date is within the last 2 days.

  6. 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




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






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!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.