# Calculating Sum of count of 2 variables squared per row

1. ## Calculating Sum of count of 2 variables squared per row

In each row I have 6 values, either an A or an R. I have 19 rows. In each row I want to count "A" and square it, and add that to the count of R squared. I can do it row by row (see column H attached) but want to be able to come up with the final sum (418) directly. Every countif and Sumproduct I've tried doesn't come close.  Register To Reply

2. ## Re: Calculating Sum of count of 2 variables squared per row

with this udf maybe ``Please Login or Register  to view this content.``
Kind regards
Leo  Register To Reply

3. ## Re: Calculating Sum of count of 2 variables squared per row

Try this...

=SUM(MMULT(--(A2:F20="A"),{1;1;1;1;1;1})^2)+SUM(MMULT(--(A2:F20="R"),{1;1;1;1;1;1})^2)  Register To Reply

4. ## Re: Calculating Sum of count of 2 variables squared per row

Thanks to both of you. Both excellent suggestions.  Register To Reply

5. ## Re: Calculating Sum of count of 2 variables squared per row

You're welcome. Thanks for the feedback!   Register To Reply