title: Calculate Max and min dates
body: <p>i'm trying to calculate the max ( and min )  of a date.</p>
  
  <p>My situation is the following.</p>
  
  <p>I've create a date table like this:</p>
  
  <pre><code>Date = 
  ADDCOLUMNS (
  CALENDAR (DATE(2008;1;1); DATE(2020;12;31));
  "DateAsInteger"; FORMAT ( [Date]; "YYYYMMDD" );
  "Year"; YEAR ( [Date] );
  "Monthnumber"; FORMAT ( [Date]; "MM" );"Daynumber"; FORMAT ( [Date]; "DD" );
  "YearMonthnumber"; FORMAT ( [Date]; "YYYY/MM" );
  "YearMonthShort"; FORMAT ( [Date]; "YYYY/mmm" );
  "MonthNameShort"; FORMAT ( [Date]; "mmm" );
  "MonthNameLong"; FORMAT ( [Date]; "mmmm" );
  "DayOfWeekNumber"; WEEKDAY ( [Date] );
  "DayOfWeek"; FORMAT ( [Date]; "dddd" );
  "DayOfWeekShort"; FORMAT ( [Date]; "ddd" );
  "Quarter"; "Q" &amp; FORMAT ( [Date]; "Q" );
  "YearQuarter"; FORMAT ( [Date]; "YYYY" ) &amp; "/Q" &amp; FORMAT ( [Date]; "Q" );
  "WeekNum"; WEEKNUM ( [Date] )
  )
  </code></pre>
  
  <p>I have a table  "Table 1" like  this :</p>
  
  <pre><code>ID  ForeignKey  Date
  1   A           01/01/2005
  2   A           05/04/2008
  3   A           31/12/2019
  4   B           15/3/2017
  5   B           16/05/2018
  6   B           15/04/2019
  7   C           05/06/2006
  8   C           04/12/2015
  9   C           15/04/2019
  </code></pre>
  
  <p> And another table "Table 2" like this
   </p>
  
  <pre><code>ID2 Price
  A   100
  B   500
  C   650
  </code></pre>
  
  <p>The "Date" table  is related to "Table1" by date and Table 1 is related to  "Table 2" by Table1.ForeignKey = Table2.ID2.</p>
  
  <p>In my report i have a date slicer which is set for example to filter dates between Jan 1 2008 and June 30 2018.
  My goal is  to calculate the max and min date for each one of table 2 in the selected period like this: </p>
  
  <pre><code>ID2 Price   MinDate         MaxDate
  A   100     05/04/2008      05/04/2008
  B   500     15/3/2017       16/05/2018
  C   650     04/12/2015      04/12/2015
  </code></pre>
  
  <p>All i am able to achieve by doing somethig like this </p>
  
  <pre><code>MaxDate= CALCULATE ( LASTDATE ( Table1[Date] ); FILTER (
  ALLSELECTED('Date') ;
  'Date'[Date] &lt;= Max('Date'[Date])
  ))
  </code></pre>
  
  <p>is the max and min dates in  the whole calendar (01/01/2008 - 12/31/2020) , which is not what i'm trying to do .</p>
  
  <p>How can I do this?</p>
  
  <p>Thanks in advance.</p>