Adding filtering to an existing query I need to simplify this code as well as a Linq query:

 var data = from linq_row in trend_data.AsEnumerable()
                       group linq_row by linq_row["questionnaire_uniquename"] into g

                       select new
                       {
                           questionnaire_uniquename = g.First&lt;DataRow&gt;()["questionnaire_uniquename"].ToString(),
                           question_name = g.First&lt;DataRow&gt;()["question_name"].ToString(),
                           question_score_type = g.First&lt;DataRow&gt;()["question_score_type"].ToString(),
                           sparkline_data = g.Select(s =&gt; s["trend_score"].ToString()).ToArray()
                       }; ;
            int rowspan = 2;


Based on some condition, I am adding just adding filtering to an existing query and modifying the selected query here. Instead of selecting question_name, I want to select response_label from a data table.

if (criteria.CorporateSummaryExpand == "1")
{
    data =
       from linq_row in trend_data.AsEnumerable()
       group linq_row by linq_row["questionnaire_uniquename"] into g
       where g.First&lt;DataRow&gt;()["questionnaire_uniquename"].ToString() != "[Questionnaire].[Questionnaire].[Question].&amp;[OFSP]&amp;[OFSP5000]"
       &amp;&amp; g.First&lt;DataRow&gt;()["questionnaire_uniquename"].ToString() != "[Questionnaire].[Questionnaire].[Question].&amp;[OFSP]&amp;[OFSP5008]"
       &amp;&amp; g.First&lt;DataRow&gt;()["questionnaire_uniquename"].ToString() != "[Questionnaire].[Questionnaire].[Question].&amp;[OFSP]&amp;[OFSP1130]"

       select new
       {
           questionnaire_uniquename = g.First&lt;DataRow&gt;()["questionnaire_uniquename"].ToString(),
           question_name = g.First&lt;DataRow&gt;()["response_label"].ToString(),
           question_score_type = g.First&lt;DataRow&gt;()["question_score_type"].ToString(),
           sparkline_data = g.Select(s =&gt; s["trend_score"].ToString()).ToArray()
       };
    rowspan = 4;
}
From what you have provided you can combine  the two queries into one. You should also consider removing constants like "1", 2, 4 with meaningful names.

var yourCondition = criteria.CorporateSummaryExpand == "1";
var data = from linq_row in trend_data.AsEnumerable()
           group linq_row by linq_row["questionnaire_uniquename"] into g
           where (criteria.CorporateSummaryExpand != "1") || (yourCondition  &amp;&amp; g.First&lt;DataRow&gt;()["questionnaire_uniquename"].ToString() != "[Questionnaire].[Questionnaire].[Question].&amp;[OFSP]&amp;[OFSP5000]"
                   &amp;&amp; g.First&lt;DataRow&gt;()["questionnaire_uniquename"].ToString() != "[Questionnaire].[Questionnaire].[Question].&amp;[OFSP]&amp;[OFSP5008]"
                   &amp;&amp; g.First&lt;DataRow&gt;()["questionnaire_uniquename"].ToString() != "[Questionnaire].[Questionnaire].[Question].&amp;[OFSP]&amp;[OFSP1130]")
           select new
           {
                questionnaire_uniquename = g.First&lt;DataRow&gt;()["questionnaire_uniquename"].ToString(),
                question_name =yourCondition  ? g.First&lt;DataRow&gt;()["response_label"].ToString() : g.First&lt;DataRow&gt;()["question_name"].ToString(),
                question_score_type = g.First&lt;DataRow&gt;()["question_score_type"].ToString(),
                sparkline_data = g.Select(s =&gt; s["trend_score"].ToString()).ToArray()
           }; 
int rowspan = yourCondition ? 4 : 2;