title: M Query Results in "Token Literal Expected"
body: <p>I am getting a &quot;Expression.SyntaxError: Token Literal Expected&quot; error in Power Query.  I know it is telling me that it expects the [OffenseTeam] to be a string literal but that is confusing as it is a reference to a field that holds the string?</p>
  <pre><code>let
  Source = Csv.Document(File.Contents(&quot;C:\Users\xxxxx\Dropbox\My PC (xxxxxx)\Desktop\pbp-2020.csv&quot;),[Delimiter=&quot;,&quot;, Columns=45, Encoding=1252, QuoteStyle=QuoteStyle.None]),
  #&quot;Promoted Headers&quot; = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
  #&quot;Changed Type&quot; = Table.TransformColumnTypes(#&quot;Promoted Headers&quot;,{{&quot;GameId&quot;, Int64.Type}, {&quot;GameDate&quot;, type date}, {&quot;Quarter&quot;, Int64.Type}, {&quot;Minute&quot;, Int64.Type}, {&quot;Second&quot;, Int64.Type}, {&quot;OffenseTeam&quot;, type text}, {&quot;DefenseTeam&quot;, type text}, {&quot;Down&quot;, Int64.Type}, {&quot;ToGo&quot;, Int64.Type}, {&quot;YardLine&quot;, Int64.Type}, {&quot;&quot;, type text}, {&quot;SeriesFirstDown&quot;, Int64.Type}, {&quot;_1&quot;, type text}, {&quot;NextScore&quot;, Int64.Type}, {&quot;Description&quot;, type text}, {&quot;TeamWin&quot;, Int64.Type}, {&quot;_2&quot;, type text}, {&quot;_3&quot;, type text}, {&quot;SeasonYear&quot;, Int64.Type}, {&quot;Yards&quot;, Int64.Type}, {&quot;Formation&quot;, type text}, {&quot;PlayType&quot;, type text}, {&quot;IsRush&quot;, Int64.Type}, {&quot;IsPass&quot;, Int64.Type}, {&quot;IsIncomplete&quot;, Int64.Type}, {&quot;IsTouchdown&quot;, Int64.Type}, {&quot;PassType&quot;, type text}, {&quot;IsSack&quot;, Int64.Type}, {&quot;IsChallenge&quot;, Int64.Type}, {&quot;IsChallengeReversed&quot;, Int64.Type}, {&quot;Challenger&quot;, type text}, {&quot;IsMeasurement&quot;, Int64.Type}, {&quot;IsInterception&quot;, Int64.Type}, {&quot;IsFumble&quot;, Int64.Type}, {&quot;IsPenalty&quot;, Int64.Type}, {&quot;IsTwoPointConversion&quot;, Int64.Type}, {&quot;IsTwoPointConversionSuccessful&quot;, Int64.Type}, {&quot;RushDirection&quot;, type text}, {&quot;YardLineFixed&quot;, Int64.Type}, {&quot;YardLineDirection&quot;, type text}, {&quot;IsPenaltyAccepted&quot;, Int64.Type}, {&quot;PenaltyTeam&quot;, type text}, {&quot;IsNoPlay&quot;, Int64.Type}, {&quot;PenaltyType&quot;, type text}, {&quot;PenaltyYards&quot;, Int64.Type}}),
  //Sorted the records by game day, by game quarter, by game minute, by game second
  #&quot;Sorted Rows&quot; = Table.Sort(#&quot;Changed Type&quot;,{{&quot;GameId&quot;, Order.Ascending}, {&quot;Quarter&quot;, Order.Ascending}, {&quot;Minute&quot;, Order.Ascending}, {&quot;Second&quot;, Order.Ascending}}),
  #&quot;Replaced Bad Q1 End&quot; = Table.ReplaceValue(#&quot;Sorted Rows&quot;,&quot;END QUARTER 1&quot;,&quot;BEGIN QUARTER 1&quot;,Replacer.ReplaceText,{&quot;Description&quot;}),
  #&quot;Replaced Bad Q2 End&quot; = Table.ReplaceValue(#&quot;Replaced Bad Q1 End&quot;,&quot;END QUARTER 2&quot;,&quot;BEGIN QUARTER 2&quot;,Replacer.ReplaceText,{&quot;Description&quot;}),
  #&quot;Replaced Bad Q3 End&quot; = Table.ReplaceValue(#&quot;Replaced Bad Q2 End&quot;,&quot;END QUARTER 3&quot;,&quot;BEGIN QUARTER 3&quot;,Replacer.ReplaceText,{&quot;Description&quot;}),
  #&quot;Replaced Bad Q4 End&quot; = Table.ReplaceValue(#&quot;Replaced Bad Q3 End&quot;,&quot;END QUARTER 4&quot;,&quot;BEGIN QUARTER 4&quot;,Replacer.ReplaceText,{&quot;Description&quot;}),
  //Filtered out the &quot;GAME&quot; and &quot;END GAME&quot; events because they don't provide any information.  There are other records that can be keyed on (e.g. 1st QTR, Minute 0, Down 1 is first play of game). 
  #&quot;Filter Out Game / End of Game&quot; = Table.SelectRows(#&quot;Replaced Bad Q4 End&quot;, each ([Description] &lt;&gt; &quot;END GAME&quot; and [Description] &lt;&gt; &quot;GAME&quot;)),
  #&quot;Create GameEventId&quot; = Table.AddColumn(#&quot;Filter Out Game / End of Game&quot;, &quot;GameEventId&quot;, each Number.ToText([GameId])&amp;if [OffenseTeam] = null and Text.Start([Description],7) = &quot;Timeout&quot; then &quot;TO&quot; else [OffenseTeam]&amp;&quot;_&quot;&amp;Number.ToText([Quarter])&amp;&quot;.&quot;&amp;Number.ToText([Minute])&amp;&quot;.&quot;&amp;Number.ToText([Second])),
  //#&quot;Create GameEventId&quot; = Table.AddColumn(#&quot;Filter Out Game / End of Game&quot;, &quot;GameEventId&quot;, each Number.ToText([GameId])&amp;[OffenseTeam] &amp;&quot;_&quot;&amp;Number.ToText([Quarter])&amp;&quot;.&quot;&amp;Number.ToText([Minute])&amp;&quot;.&quot;&amp;Number.ToText([Second])),
  #&quot;Reordered Columns&quot; = Table.ReorderColumns(#&quot;Create GameEventId&quot;,{&quot;GameEventId&quot;, &quot;GameId&quot;, &quot;GameDate&quot;, &quot;Quarter&quot;, &quot;Minute&quot;, &quot;Second&quot;, &quot;OffenseTeam&quot;, &quot;DefenseTeam&quot;, &quot;Down&quot;, &quot;ToGo&quot;, &quot;YardLine&quot;, &quot;&quot;, &quot;SeriesFirstDown&quot;, &quot;_1&quot;, &quot;NextScore&quot;, &quot;Description&quot;, &quot;TeamWin&quot;, &quot;_2&quot;, &quot;_3&quot;, &quot;SeasonYear&quot;, &quot;Yards&quot;, &quot;Formation&quot;, &quot;PlayType&quot;, &quot;IsRush&quot;, &quot;IsPass&quot;, &quot;IsIncomplete&quot;, &quot;IsTouchdown&quot;, &quot;PassType&quot;, &quot;IsSack&quot;, &quot;IsChallenge&quot;, &quot;IsChallengeReversed&quot;, &quot;Challenger&quot;, &quot;IsMeasurement&quot;, &quot;IsInterception&quot;, &quot;IsFumble&quot;, &quot;IsPenalty&quot;, &quot;IsTwoPointConversion&quot;, &quot;IsTwoPointConversionSuccessful&quot;, &quot;RushDirection&quot;, &quot;YardLineFixed&quot;, &quot;YardLineDirection&quot;, &quot;IsPenaltyAccepted&quot;, &quot;PenaltyTeam&quot;, &quot;IsNoPlay&quot;, &quot;PenaltyType&quot;, &quot;PenaltyYards&quot;}),
  #&quot;Replaced LA with LAR - Off&quot; = Table.ReplaceValue(#&quot;Reordered Columns&quot;,&quot;LA&quot;,&quot;LAR&quot;,Replacer.ReplaceValue,{&quot;OffenseTeam&quot;}),
  #&quot;Replaced LA with LAR - Def&quot; = Table.ReplaceValue(#&quot;Replaced LA with LAR - Off&quot;,&quot;LA&quot;,&quot;LAR&quot;,Replacer.ReplaceValue,{&quot;DefenseTeam&quot;}),
  //Got rid of records for beginning of quarters and 2-minute warnings
  #&quot;Filter Out Procedural Records&quot; = Table.SelectRows(#&quot;Replaced LA with LAR - Def&quot;, each [Description] &lt;&gt; &quot;BEGIN QUARTER 1&quot; and [Description] &lt;&gt; &quot;BEGIN QUARTER 2&quot; and [Description] &lt;&gt; &quot;BEGIN QUARTER 3&quot; and [Description] &lt;&gt; &quot;BEGIN QUARTER 4&quot; and not Text.StartsWith([Description], &quot;THE GAME&quot;) and [Description] &lt;&gt; &quot;TWO-MINUTE WARNING&quot;),
  #&quot;Reordered Columns1&quot; = Table.ReorderColumns(#&quot;Filter Out Procedural Records&quot;,{&quot;GameEventId&quot;, &quot;GameId&quot;, &quot;GameDate&quot;, &quot;Quarter&quot;, &quot;Minute&quot;, &quot;Second&quot;, &quot;OffenseTeam&quot;, &quot;DefenseTeam&quot;, &quot;Down&quot;, &quot;ToGo&quot;, &quot;YardLine&quot;, &quot;Description&quot;, &quot;&quot;, &quot;SeriesFirstDown&quot;, &quot;_1&quot;, &quot;NextScore&quot;, &quot;TeamWin&quot;, &quot;_2&quot;, &quot;_3&quot;, &quot;SeasonYear&quot;, &quot;Yards&quot;, &quot;Formation&quot;, &quot;PlayType&quot;, &quot;IsRush&quot;, &quot;IsPass&quot;, &quot;IsIncomplete&quot;, &quot;IsTouchdown&quot;, &quot;PassType&quot;, &quot;IsSack&quot;, &quot;IsChallenge&quot;, &quot;IsChallengeReversed&quot;, &quot;Challenger&quot;, &quot;IsMeasurement&quot;, &quot;IsInterception&quot;, &quot;IsFumble&quot;, &quot;IsPenalty&quot;, &quot;IsTwoPointConversion&quot;, &quot;IsTwoPointConversionSuccessful&quot;, &quot;RushDirection&quot;, &quot;YardLineFixed&quot;, &quot;YardLineDirection&quot;, &quot;IsPenaltyAccepted&quot;, &quot;PenaltyTeam&quot;, &quot;IsNoPlay&quot;, &quot;PenaltyType&quot;, &quot;PenaltyYards&quot;}),
  #&quot;Removed Columns&quot; = Table.RemoveColumns(#&quot;Reordered Columns1&quot;,{&quot;_1&quot;, &quot;_2&quot;, &quot;_3&quot;, &quot;NextScore&quot;, &quot;&quot;, &quot;Challenger&quot;}),
  #&quot;Reordered Columns2&quot; = Table.ReorderColumns(#&quot;Removed Columns&quot;,{&quot;GameEventId&quot;, &quot;GameId&quot;, &quot;GameDate&quot;, &quot;Quarter&quot;, &quot;Minute&quot;, &quot;Second&quot;, &quot;OffenseTeam&quot;, &quot;DefenseTeam&quot;, &quot;Down&quot;, &quot;ToGo&quot;, &quot;YardLineDirection&quot;, &quot;YardLine&quot;, &quot;Description&quot;, &quot;SeriesFirstDown&quot;, &quot;TeamWin&quot;, &quot;SeasonYear&quot;, &quot;Yards&quot;, &quot;Formation&quot;, &quot;PlayType&quot;, &quot;IsRush&quot;, &quot;IsPass&quot;, &quot;IsIncomplete&quot;, &quot;IsTouchdown&quot;, &quot;PassType&quot;, &quot;IsSack&quot;, &quot;IsChallenge&quot;, &quot;IsChallengeReversed&quot;, &quot;IsMeasurement&quot;, &quot;IsInterception&quot;, &quot;IsFumble&quot;, &quot;IsPenalty&quot;, &quot;IsTwoPointConversion&quot;, &quot;IsTwoPointConversionSuccessful&quot;, &quot;RushDirection&quot;, &quot;YardLineFixed&quot;, &quot;IsPenaltyAccepted&quot;, &quot;PenaltyTeam&quot;, &quot;IsNoPlay&quot;, &quot;PenaltyType&quot;, &quot;PenaltyYards&quot;})
  </code></pre>
  <p>in
  #&quot;Reordered Columns2&quot;</p>
  <p>The error is occuring here:</p>
  <pre><code>#&quot;Filter Out Game / End of Game&quot; = Table.SelectRows(#&quot;Replaced Bad Q4 End&quot;, each ([Description] &lt;&gt; &quot;END GAME&quot; and [Description] &lt;&gt; &quot;GAME&quot;)),
  #&quot;Create GameEventId&quot; = Table.AddColumn(#&quot;Filter Out Game / End of Game&quot;, &quot;GameEventId&quot;, each Number.ToText([GameId])&amp;if [OffenseTeam] = null and Text.Start([Description],7) = &quot;Timeout&quot; then &quot;TO&quot; else [OffenseTeam]&amp;&quot;_&quot;&amp;Number.ToText([Quarter])&amp;&quot;.&quot;&amp;Number.ToText([Minute])&amp;&quot;.&quot;&amp;Number.ToText([Second])),
  </code></pre>
  <p>Does it have to do with the Each?</p>