title: Measure in DAX to calculate YTD for chosen month only for Power BI
body: <p>How to construct DAX measure to calculate sum of YTD value for specific month? </p>
  
  <p>Here we have FactTable grouped by months. FactTable is filled with both Actual data and Forecast data. The only way to know when Actual end is information in table [Cut of date] in column [End of YTD]. In table [Cut of date] in column [End of YTD] – it is a single value table – we have the interesting chosen month, for which we want to see the calculation of YTD. In our case it is March. FactTable is updated irregularly every month with usually one month delay. There is no way of linking it to time functions like TODAY because of irregular update.</p>
  
  <p><a href="https://i.stack.imgur.com/hNT6A.png" rel="noreferrer"><img src="https://i.stack.imgur.com/hNT6A.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/IckCi.png" rel="noreferrer"><img src="https://i.stack.imgur.com/IckCi.png" alt="enter image description here"></a>
  We would like to have a correct value of YTD displayed in yellow Card Visual for the month [End of YTD]. When we click on the slicer on "2018-03" we get almost what we want – correct value of 66 in the yellow Card. However this solution is not automatic. I want to see correct value automatically when the [End of YTD] month changes, in our case to April or then to May. I do not want it done by user. </p>
  
  <p>My desperate effort can be downloaded from file: <a href="https://drive.google.com/uc?authuser=0&amp;id=10C4HJWy2H_PmfGfn8jobalpjzlNqL2ff&amp;export=download" rel="noreferrer">DAX YTD.pbix</a></p>
  
  <p>I pursued the deer in various ways:</p>
  
  <ol>
  <li>By using <strong>FILTER</strong> function in DAX measures. But it seems that the
  FILTER function is to harsh. It is applied to fact table first,
  selecting only one month, and then calculating YTD value wrongly. So if
  there would be any option for <strong>forcing order of calculation and filtering</strong>, there would
  be hope. </li>
  <li>I tried <strong>SWITCH</strong> function to display proper result
  for specific month and 0 or null for other months. Although I
  succeed in this, I was not able to take advantage of it. When it
  came to filtering I was as hopeless as before. BTW I would be able
  to make it if SWITCH produced totals at the end of the table, but it
  does not. Surprisingly.</li>
  <li>I put some hopes in <strong>RELATED</strong> function to display proper results in the [Cut off date] table. I have not walk out of the fog so far. </li>
  </ol>
  
  <p>I would appreciate your help. </p>
  
  <p><strong>Update before bounty.</strong>
  Going to higher level. I have introduced a Category column to FactTable. Please download <a href="https://drive.google.com/uc?authuser=0&amp;id=1eEqrS2-NybuI-K2rb9zaFsREyAiyCp-i&amp;export=download" rel="noreferrer">DAX YTD by category.pbix</a>. So filtering gets more complex now. I would like to have correct YTD figures for Apples category. </p>