title: Calculate average for grouped field using c# LINQ
body: <p>There are someone can help me for calculating an average using c# Linq, for the folowing data :</p>
  
  <pre><code>Year    city1   city2   value  
  2016    CIT01   CIT01   578
  2016    CIT01   CIT02   1067
  2016    CIT01   CIT03   17
  2016    CIT02   CIT01   1105
  2016    CIT02   CIT02   233
  2016    CIT02   CIT03   0
  2016    CIT03   CIT01   1425
  2016    CIT03   CIT02   231
  2016    CIT03   CIT03   1398
  2017    CIT01   CIT01   185
  2017    CIT01   CIT02   69
  2017    CIT01   CIT03   2225
  2017    CIT02   CIT01   0
  2017    CIT02   CIT02   104
  2017    CIT02   CIT03   258
  2017    CIT03   CIT01   10
  2017    CIT03   CIT02   342
  2017    CIT03   CIT03   643
  2018    CIT01   CIT01   59
  2018    CIT01   CIT02   163
  2018    CIT01   CIT03   284
  2018    CIT02   CIT01   19
  2018    CIT02   CIT02   379
  2018    CIT02   CIT03   462
  2018    CIT03   CIT01   46
  2018    CIT03   CIT02   0
  2018    CIT03   CIT03   154
  </code></pre>
  
  <p>In example, I would like to get average of :<br>
  2016    CIT01   CIT01   578<br>
  2017    CIT01   CIT01   185<br>
  2018    CIT01   CIT01   59</p>
  
  <p>Output:</p>
  
  <pre><code>Year   city1   city2   value
  -----------------------------
  Prev    CIT01   CIT01   274
  Prev    CIT01   CIT02   433
  Prev    CIT01   CIT03   842
  Prev    CIT02   CIT01   375
  Prev    CIT02   CIT02   239
  Prev    CIT02   CIT03   240
  Prev    CIT03   CIT01   494
  Prev    CIT03   CIT02   191
  Prev    CIT03   CIT03   732
  </code></pre>