In cell P1, paste the following formula:
=IF(ISNUMBER(SEARCH("rev",B1)),A1,)
Use the mouse to extend the formula to the right to cell Y1.
The formula does a caseinsensitive search of the cell to see if it
contains "rev". This will capture "Revenue", "revenue", and "rev".
If there's a match, then it copies the cell to the left. Otherwise it
enters 0.
Now, in cell Z1, simply sum cells P1 th

Your main question seems to be how to calculate distances between a
data matrix and some set of points ("centers").
For this you can write a function that takes as input a data matrix
and your set of points and returns distances for each row (point) in
the data matrix to all the "centers".
Here is such a function:
myEuclid < function(points1, points2) {
distanceMatrix < matrix(NA, n

You can convert all nan values to zeros using np.nan_to_num() and then
proceed further. Demo:
>>> data
array([[ 5.1, 3.5, 1.4, 0.2],
[ 4.9, 3. , nan, 0.2],
[ 4.7, 3.2, 1.3, nan],
[ nan, 3.1, 1.5, 0.2]])
>>> np.cov(data.T)
array([[ nan, nan, nan, nan],
[ nan, 0.04666667, nan, nan],
