title: Set MetricAggregations with Google Analytics Api
body: <p>I code in C# and use Google.Analytics.Data.V1Beta library to retrieve GA4 data.</p>
  <p>The query I would like to send to the api is the following :</p>
  <pre><code>{
  &quot;dimensions&quot;: [
      {
          &quot;name&quot;: &quot;pageLocation&quot;
      }
  ],
  &quot;metrics&quot;: [
      {
          &quot;name&quot;: &quot;screenPageViews&quot;
      }
  ],
  &quot;dateRanges&quot;: [
      {
          &quot;startDate&quot;: &quot;2022-01-01&quot;,
          &quot;endDate&quot;: &quot;2022-07-19&quot;
      }
  ],
  &quot;dimensionFilter&quot;: {
      &quot;filter&quot;: {
          &quot;stringFilter&quot;: {
              &quot;matchType&quot;: &quot;PARTIAL_REGEXP&quot;,
              &quot;value&quot;: &quot;l-\\d{6,}&quot;
          },
          &quot;fieldName&quot;: &quot;pageLocation&quot;
      }
  },
  &quot;limit&quot;: &quot;1&quot;,
  &quot;metricAggregations&quot;: [
      &quot;TOTAL&quot;
  ]}
  </code></pre>
  <p>The important part of the query is the metricAggregations property.
  Here is my code</p>
  <pre><code>var request = new RunReportRequest
    {
      Property = &quot;properties/&quot; + myPropertyId,
      Dimensions = {
        new Dimension { Name = &quot;pageLocation&quot; }
      },
      DimensionFilter = new FilterExpression
      {
        Filter = new Filter
        {
          StringFilter = new Filter.Types.StringFilter { 
            CaseSensitive = true, 
            MatchType = Filter.Types.StringFilter.Types.MatchType.PartialRegexp, 
            Value = @&quot;l-\d{6,}&quot; 
          },
          FieldName = &quot;pageLocation&quot;
        }
      },
      Metrics = {
        new Metric { Name = &quot;screenPageViews&quot; }
      },
      MetricAggregations=new Google.Protobuf.Collections.RepeatedField&lt;MetricAggregation&gt; { MetricAggregation.Total},
      DateRanges = {
        new DateRange {
          StartDate = &quot;2022-01-01&quot;,
          EndDate = &quot;2022-07-19&quot;
        }
      },
    };
  
    // Make the request
    var response = await _client.RunReportAsync(request);
  </code></pre>
  <p>The problem is that MetricAggregations property is a readonly property so it raises an error.</p>
  <p>The error displayed is &quot;Aggregation of metrics. Aggregated metric values will be shown in rows where the dimensionValues are set to &quot;RESERVED_(MetricAggregation)&quot;.</p>
  <p>Can somebody tell me how I can set this parameter with c# library ?</p>
  <p>Regards</p>