# Dax Measure Help - Calculate with Max/min for dates



## kzmanus (Feb 18, 2012)

What I am trying to do is add a variance column (max(receiver date) - min(receive date) to obtain the number of days between 1st receive and last. 

This formula is wrong =CALCULATE(MAX(MRR[Received Date]-MIN(MRR[Received Date]),ALL(MRR[Received Date]))

Any advice?

Thanks

Kevin


----------



## powerpivotpro (Feb 20, 2012)

A few ideas.



You might try ALL(MRR) and not just ALL(MRR[Received Date]) - if there are other fields from the MRR table on your pivot, clearing the [Received Date] filter isn't enough - you need to clear all filters.  For instance if you have [Month] on your pivot, ALL(MRR[Received Date]) will still leave the [Month] filter in place, which obviously impacts [Received Date] as well.
I would write this as two separate CALCULATE'S, one for the MIN and one for the MAX, and then subtracting one from the other - for me that's a stylistic concern, I doubt it is impacting your actual result, but I've never tried it your way.
You might want to try FIRSTDATE and LASTDATE instead of MIN and MAX.
You should check to make sure your [Received Date] column hasn't been imported as text.


----------

