If I understand you correctly, you want to put the total number of voices of all of your channels into the display of the dialog..not just the current channel. If so, here's a re-write of your code.
alias stats {
var %ops = 0, %voice = 0, %Lin = 1, %b = $chan(0)
while %Lin <= %b {
did -a stats 3 0 1 $chan(%Lin).topic $chr(9) $nick($chan(%Lin),0,o) $chr(9) $nick($chan(%Lin),0,v)
did -a stats 5 0 2 $server
inc %ops $nick($chan(%Lin),0,o)
inc %voice $nick($chan(%Lin),0,v)
inc %Lin
}
did -ra stats <ID> Total Ops: %ops
did -ra stats <ID> Total Voice: %voice
}
I'm going to presume that this alias is designed to work with a dialog that you already have, so you'll have to fill in the ID's for the last two lines that require them.
If you have any problems understanding my code, and if I got your request correct, specify what you don't understand and I'll try to clarify.