Can only one loop be used to calculate percentage?
No, totatVal won't be a totalVal until you loop through all the rows to find it.
It might be solved by a single loop with some fancy standard functions but at the end it will come down to 2 loops. 

It's pure math - you need to count your total value first in order to find a correct % of each of your values.