You still want all of the rows, but with the total per Ref on each row?
LEFT JOIN (MyTable) LOAD Ref ,count(no) as tot RESIDENT MyTable ;
That said, I generally recommend against doing totals in the script, as they won't be sensitive to selections. Of course, if you WANT your totals to not be sensitive to selections, the script is a good place to do that. But otherwise, this would normally be handled in a chart. Something like this:
The reason I am trying to do this in the load script is because I need to include the data within a pivot table against the reference; the pivot being on date and containing other information. Using a count/sum calculation within the dimension just seemed to break the table, I think doing it this way will give a cleaner result (or at least one that will work).