You still want all of the rows, but with the total per Ref on each row?
LEFT JOIN (MyTable)
,count(no) as tot
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:
dimension 1 = Ref
dimension 2 = no
expression = count(total <Ref> no)
Many thanks for that answer.
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).