In your example, what the the 2 and 4 represent? 2 records of type, size or the sum of a quantify field?
The basic solution is to define a summry field that computes either the count of a nonblank record or the total of a quantity field. On a list view layout, remove the body layout part and replace it with a sub summary layout part "when sorted by Type" or "when sorted by size" (Pick one or the other depending on how you want the rows of data ordered in your report.)
You can then sort your records by both type and size fields. If you sort by type, then size and use "when sorted by size", you can group your records by type, then by size and show your subtotals for each combination of type and size.
If you sort your records by size, then type and specify "when sorted by type" in the sub summary layout part, you can group your recors by size, then show a total for each type.
In either approach, the same summary fields placed in a trailing grand summary part will display a total for all your records in the found set.
The example 2 & 4 were just an example of the totals sum of each type.
The body is being used to list all products on site.
can I create sub summary that can show the amounts and totals to print on the last page only and what function name would I need to use
Sub summary layout parts are used to report totals for sorted groups of records.
If you were to print out a summary report like this
Product sub total for product X
Individual item recors for product X listed here
Product totals for product Y
individual item recors for product Y...
and so forth.
You can also put the sub summary part after the group of individual records to show subtotals below the group of records.
It takes much less work to set up that type of report than to try to add a "recap" list of totals at the end--which can't be done with a sub summary layout part.
A portal to a table where you have one record for each product-size combination could be used for such a final page, but only if you can list all those entries in your portal--so it's easier to pull off if your report lists only a fairly small number of products.
You could also create the original report layout that I described and use save as PDF to generate your report. Save as PDF as part of a script gives you the option to append a PDF generated by it to the end of an existing PDF, so you could use Save As PDF to create the first part of your report listing the individual items and then you change layouts to a second layout with the sub summary layout parts to produce a PDF of the totals to append to the end of the first PDF. The main limitation to this approach is that your totals would start on their own page--not be merged onto the last page of your report.