Query in linq

I need to write a query in the Assign activity.
There are city, model and price columns in Excel. I will print how many models there are in each city and the average price of the models in each city. and it should not see the ‘$’ symbol when averaging the prices because I can’t get it as an integer
image

Similar to:

@Busra1 as @ppr said, it’s really similar to your other post.

The only difference is the “$” on the prices. If you want to get the sums without the “$” since it will not detect it as INT (Or Double), you can do the following:

var_dt.AsEnumerable.Where(
	Function(x) x("City").ToString.Equals(City)
).Sum(
	Function(y) CDbl(System.Text.RegularExpressions.Regex.Matches((y("Price").ToString),"[0-9]+[\.|\,]*[0-9]*")(0).ToString)
)/var_dt.AsEnumerable.Where(Function(x) x("City").ToString.Equals(City)).Count
  • Result = Double variable

The different part with the answer on the other post is this part:

CDbl(System.Text.RegularExpressions.Regex.Matches((y("Price").ToString),"[0-9]+[\.|\,]*[0-9]*")(0).ToString)

Which gets the numbers, with optional “.” and “,” as separators, for example, “500,50 $”

image

image