I need to get the AVG of each “City/Town” Price in different sheet. I cannot use data filter because of a lot datas.
Notes : Some datas has got space. I mean for example " Bulgurlu " like that.
in Price, There is a dots between numbers and end of the TL(String)
So can u help me?? If you need more info i can explain.
(
From row In dt_Data
Group row By
k= Strings.StrConv(Regex.Replace(row("City/Town").ToString, "\s+", " ").Trim, VbStrConv.ProperCase)
Into grp=Group
Let avg = grp.Average(Function(gr) Double.Parse(gr("Price").ToString.Replace("TL", "").Trim(), CultureInfo.GetCultureInfo("tr-TR")))
Let sum = grp.Sum(Function(gr) Double.Parse(gr("Price").ToString.Replace("TL", "").Trim(), CultureInfo.GetCultureInfo("tr-TR")))
Select dt_Result.Rows.Add({k, grp.Count, sum, avg})
).CopyToDataTable
My_Datas => Read Range Output(DataTable)
New_Dt => Build Data Table Output(DataTable)
My_Code :
(
From row In My_Datas
Group row By k = Strings.StrConv(Regex.Replace(row("City/Town").ToString, "\s+", " ").Trim, VbStrConv.ProperCase)
Into grp = Group
Let avg = grp.Average(Function(gr) Double.Parse(gr("Price").ToString.Replace("TL","").Trim(), CultureInfo.GetCultureInfo("tr-TR")))
Let sum = grp.Sum(Function(gr) Double.Parse(gr("Price").ToString.Replace("TL","").Trim(), CultureInfo.GetCultureInfo("tr-TR")))
Select New_Dt.Rows.Add({k, grp.Count, sum, avg})
).CopyToDataTable