using System.Collections.Generic;
public static void Main()
var data = new List<SummaryTabData>()
new() { LP = "LP_1", assetClass = "Asset_CFD_Long", avgSlippagePts = 54.23 },
new() { LP = "LP_1", assetClass = "Asset_FX_Long", avgSlippagePts = 61.41 },
new() { LP = "LP_1", assetClass = "Asset_FX_Short", avgSlippagePts = 11.48 },
new() { LP = "LP_1", assetClass = "Asset_CFD_Short", avgSlippagePts = 63.51 },
new() { LP = "LP_2", assetClass = "Asset_FX_Long", avgSlippagePts = 6.51 },
new() { LP = "LP_2", assetClass = "Asset_FX_Short", avgSlippagePts = 13.51 }
.ThenByDescending(x => x.assetClass).ToList();
.Select(x => new { Asset = x.assetClass.Split("_")[1], Summary = x })
.GroupBy(x => new { x.Asset, x.Summary.LP });
foreach (var group in groups)
var index = data.IndexOf(bob.Summary);
assetClass = $"{bob.Asset}_Total",
avgSlippagePts = group.Sum(x => x.Summary.avgSlippagePts)
foreach (var item in data)
Console.WriteLine($"{item.LP}, {item.assetClass}, {item.avgSlippagePts}");
public class SummaryTabData
public string LP { get; set; }
public string assetClass { get; set; }
public double avgSlippagePts { get; set; }