title: Excel Power Query failing on adding Date Column
body: <p>So, I have data with a date (<code>CLOSE_DATE</code>) / value (<code>KG_A7</code>) pair where I am grouping (sum) the value over a month (using the first of the month as the column to group by).  I can do this manually but am trying to write a function (fnGroupByMonth) as I need to do this transformation for different data sources.</p>
  <p>I have working code:</p>
  <pre><code>let 
      fnGroupByMonth = (SourceTable, GroupBy as text, Values as text) =&gt;
      let
          #&quot;Inserted Start of Month&quot; = Table.AddColumn(SourceTable, &quot;Month&quot;, each Date.From(Date.StartOfMonth([CLOSE_DATE])), type date),
          #&quot;Grouped Rows&quot; = Table.Group(#&quot;Inserted Start of Month&quot;, {&quot;Month&quot;}, {{Values, each List.Sum([KG_A7]), type number}}),
          #&quot;Sorted Rows&quot; = Table.Sort(#&quot;Grouped Rows&quot;,{{&quot;Month&quot;, Order.Ascending}})
      in
          #&quot;Sorted Rows&quot;
  in
      fnGroupByMonth
  </code></pre>
  <p>But when I try to change (1) <code>[CLOSE_DATE]</code> for <code>Table.Column(SourceTable, GroupBy)</code> or (2) <code>[KG_A7]</code> for <code>Table.Column(SourceTable, Values)</code> I get the following errors:</p>
  <p>(1) <em>The Date value must contain the Date component Details:
  [List]</em></p>
  <p>(2) The same sum of Values for each month</p>
  <p>I have tried without the <code>as text</code> and I have tried sending the column names as columns (so <code>[CLOSE_DATE]</code> instead of <code>&quot;CLOSE_DATE&quot;</code>, in which case I get the error &quot;<em>There is an unknown identifier. Did you use the [field] shorthand for a _[field] outside of an 'each' expression?</em>&quot;</p>